Example #1
0
 def test_format_time(self):
     self.failUnlessEqual(time_format.format_time(time.gmtime(0)),
                          '1970-01-01 00:00:00')
     self.failUnlessEqual(time_format.format_time(time.gmtime(60)),
                          '1970-01-01 00:01:00')
     self.failUnlessEqual(time_format.format_time(time.gmtime(60 * 60)),
                          '1970-01-01 01:00:00')
     seconds_per_day = 60 * 60 * 24
     leap_years_1970_to_2014_inclusive = ((2012 - 1968) // 4)
     self.failUnlessEqual(
         time_format.format_time(
             time.gmtime(seconds_per_day * (
                 (2015 - 1970) * 365 + leap_years_1970_to_2014_inclusive))),
         '2015-01-01 00:00:00')
Example #2
0
 def test_format_time_y2038(self):
     seconds_per_day = 60 * 60 * 24
     leap_years_1970_to_2047_inclusive = ((2044 - 1968) // 4)
     t = (seconds_per_day *
          ((2048 - 1970) * 365 + leap_years_1970_to_2047_inclusive))
     try:
         gm_t = time.gmtime(t)
     except ValueError:
         raise unittest.SkipTest(
             "Note: this system cannot handle dates after 2037.")
     self.failUnlessEqual(time_format.format_time(gm_t),
                          '2048-01-01 00:00:00')
Example #3
0
def render_time_attr(t):
    return format_time(time.localtime(t))
Example #4
0
def render_time(t):
    return spaces_to_nbsp(format_time(time.localtime(t)))
Example #5
0
def render_time_attr(t):
    return format_time(time.localtime(t))
Example #6
0
def render_time(t):
    return spaces_to_nbsp(format_time(time.localtime(t)))
Example #7
0
 def nice_current_time(self):
     return format_time(datetime.fromtimestamp(self._clock.seconds()).timetuple())