def index_to_interval(self, partition_index): unix_timestamp_start = partition_index * self.size unix_timestamp_end = unix_timestamp_start + self.size start = from_unix_timestamp(unix_timestamp_start) end = from_unix_timestamp(unix_timestamp_end) return start, end
def test_from_unix_timestamp(): timestamp = from_unix_timestamp(0) expected_timestamp = pytz.utc.localize(datetime(1970, 1, 1, 0, 0, 0)) eq_(timestamp, expected_timestamp) timestamp = from_unix_timestamp(1365022800) expected_timestamp = pytz.utc.localize(datetime(2013, 4, 3, 21, 0, 0)) eq_(timestamp, expected_timestamp)