示例#1
0
  def test_localtime_to_utc(self):
    dt = datetime.now()
    self.assertEquals(repeat.utc_to_localtime(repeat.localtime_to_utc(dt)),
                      dt)

    src = datetime(2012, 12, 8, 16, 32, 49)
    self.assertEquals(repeat.localtime_to_utc(src),
                      datetime(2012, 12, 9, 0, 32, 49))
示例#2
0
  def test_daily_next(self):
    helper_noon = repeat.daily_helper(time(12, 0, 0))
    helper_midnight = repeat.daily_helper(time(0, 0, 0))

    # Noon - Morning
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 3, 21, 17))
    result = helper_noon(now)
    self.assertEquals(result, datetime(2012, 2, 13, 20, 0))

    # Noon - Evening
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 17, 21, 17))
    result = helper_noon(now)
    self.assertEquals(result, datetime(2012, 2, 14, 20, 0))

    # Noon - Month/Year wrap
    now = repeat.localtime_to_utc(datetime(2012, 12, 31, 23, 59, 59))
    result = helper_noon(now)
    self.assertEquals(result, datetime(2013, 1, 1, 20, 0))

    # Midnight - Morning
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 3, 21, 17))
    result = helper_midnight(now)
    self.assertEquals(result, datetime(2012, 2, 14, 8, 0))

    # Midnight - Evening
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 13, 21, 17))
    result = helper_midnight(now)
    self.assertEquals(result, datetime(2012, 2, 14, 8, 0))

    # Midnight - Midnight
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 0, 0, 0))
    result = helper_midnight(now)
    self.assertEquals(result, datetime(2012, 2, 14, 8, 0))

    # Odd Time
    now = repeat.localtime_to_utc(datetime(2012, 2, 13, 3, 21, 17))
    result = repeat.daily_next(now, time(13, 37, 19))
    self.assertEquals(result, datetime(2012, 2, 13, 21, 37, 19))