示例#1
0
 def test_format_without_tzinfo(self):  # noqa
     """Format times without timezone info"""
     dt = self.sometime_univ
     auckland = 'Pacific/Auckland'
     est = 'EST'
     ams = 'Europe/Amsterdam'
     self.assertEquals(times.format(dt, auckland),
                       '2012-02-02T00:56:31+13:00')
     self.assertEquals(times.format(dt, ams), '2012-02-01T12:56:31+01:00')
     self.assertEquals(times.format(dt, est), '2012-02-01T06:56:31-05:00')
示例#2
0
    def test_convert_unix_time_to_datetime(self):  # noqa
        """Can convert from UNIX time to universal time."""
        unix_time = 1328257004.456  # as returned by time.time()
        self.assertEquals(
            times.from_unix(unix_time),
            pytz.utc.localize(datetime(2012, 2, 3, 8, 16, 44, 456000))
        )

        self.assertEquals(
            times.format(times.from_unix(unix_time), 'UTC'),
            '2012-02-03T08:16:44.456000+00:00')
        self.assertEquals(
            times.format(times.from_unix(unix_time), 'Europe/Amsterdam'),
            '2012-02-03T09:16:44.456000+01:00')
        self.assertEquals(
            times.format(times.from_unix(unix_time), 'Pacific/Auckland'),
            '2012-02-03T21:16:44.456000+13:00')
示例#3
0
 def test_custom_format(self):
     dt = self.sometime_univ
     auckland = 'Pacific/Auckland'
     est = 'EST'
     self.assertEquals(times.format(dt, auckland, '%H'), '00')
     self.assertEquals(times.format(dt, est, '%H'), '06')