def test_gen_time(self): s = datetime(2012, 1, 1) e = datetime(2012, 1, 1, 11, 59, 59) i = timedelta(hours=2) expected = [datetime(2012, 1, 1, hour, 0, 0) for hour in [0, 2, 4, 6, 8, 10]] result = [t for t in time_utils.gen_time(s, e, i)] self.assertEqual(result, expected)
def test_gen_time(self): s = datetime(2012, 1, 1) e = datetime(2012, 1, 1, 11, 59, 59) i = timedelta(hours=2) expected = [ datetime(2012, 1, 1, hour, 0, 0) for hour in [0, 2, 4, 6, 8, 10] ] result = [t for t in time_utils.gen_time(s, e, i)] self.assertEqual(result, expected)
def __init__(self, start, end, interval_size): self.start = start self.end = end self.interval_size = interval_size self.possible_intervals = list(time_utils.gen_time(start, end, interval_size))