def test_to_UNIXtime(self): unix = 1378459200 iso = "2013-09-06 09:20:00+00" date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC()) self.assertEqual(unix, timeformatutils.to_UNIXtime(unix)) self.assertEqual(unix, timeformatutils.to_UNIXtime(iso)) self.assertEqual(unix, timeformatutils.to_UNIXtime(date))
def test_to_ISO8601(self): unixtime = 1378459200 iso = "2013-09-06 09:20:00+00" date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC()) self.assertEqual(iso, timeformatutils.to_ISO8601(unixtime)) self.assertEqual(iso, timeformatutils.to_ISO8601(iso)) self.assertEqual(iso, timeformatutils.to_ISO8601(date))
def test_timeformat(self): unixtime = 1378459200 iso = "2013-09-06 09:20:00+00" date = datetime(2013, 9, 6, 9, 20, 0, tzinfo=timeformatutils.UTC()) self.assertEqual(unixtime, timeformatutils.timeformat(unixtime, "unix")) self.assertEqual(iso, timeformatutils.timeformat(unixtime, "iso")) self.assertEqual(date, timeformatutils.timeformat(unixtime, "date")) self.assertEqual(unixtime, timeformatutils.timeformat(iso, "unix")) self.assertEqual(iso, timeformatutils.timeformat(iso, "iso")) self.assertEqual(date, timeformatutils.timeformat(iso, "date")) self.assertEqual(unixtime, timeformatutils.timeformat(date, "unix")) self.assertEqual(iso, timeformatutils.timeformat(date, "iso")) self.assertEqual(date, timeformatutils.timeformat(date, "date"))
def test_datetime_to_UNIXtime(self): date = datetime(2013, 9, 19, 12, 0, tzinfo=timeformatutils.UTC()) expected = 1379592000 self.assertEqual(timeformatutils._datetime_to_UNIXtime(date), expected)