Ejemplo n.º 1
0
 def test_to_unix_timestamp(self):
     ts = SystemTimestamp(2018, 2, 11, 8, 38, 0, 0)
     self.assertEqual(1518338280.0, ts.to_unix_timestamp())
Ejemplo n.º 2
0
 def test_to_string_tz(self):
     expiry_date = SystemTimestamp(2015, 1, 30, 15, 0, 0, 0).to_datetime()
     self.assertEqual(datetime(2015, 1, 30, 15, 0, 0, 0, tzinfo=timezone.utc), expiry_date)
Ejemplo n.º 3
0
 def test_from_string(self):
     self.assertEqual(SystemTimestamp(2018, 2, 11, 8, 38, 0, 0),
                      SystemTimestamp.from_string("2018-02-11 08:38:00.000000"))
Ejemplo n.º 4
0
 def test_from_string_iso(self):
     self.assertEqual(SystemTimestamp(2018, 2, 11, 8, 38, 0, 0),
                      SystemTimestamp.from_string("2018-02-11T08:38:00.000000Z", format=FORMAT_ISO8601))
Ejemplo n.º 5
0
 def test_to_string_iso(self):
     ts = SystemTimestamp(2018, 2, 11, 8, 38, 0, 0)
     self.assertEqual("2018-02-11T08:38:00.000000Z", ts.to_string_iso8601())
Ejemplo n.º 6
0
 def test_to_string(self):
     ts = SystemTimestamp(2018, 2, 11, 8, 38, 0, 0)
     self.assertEqual("2018-02-11 08:38:00.000000", ts.to_string())
Ejemplo n.º 7
0
 def test_to_datetime(self):
     ts = SystemTimestamp(2018, 2, 11, 8, 38, 0, 0)
     self.assertEqual(datetime(2018, 2, 11, 8, 38, 0, 0, tzinfo=timezone.utc), ts.to_datetime())
Ejemplo n.º 8
0
 def test_from_datetime(self):
     dt = datetime(2018, 2, 11, 8, 38, 0, 0, tzinfo=timezone.utc)
     ts = SystemTimestamp(2018, 2, 11, 8, 38, 0, 0)
     self.assertEqual(ts, SystemTimestamp.from_datetime(dt))
Ejemplo n.º 9
0
 def test_default(self):
     ts = SystemTimestamp()
     print(datetime.now(JST).astimezone(tz=timezone.utc))
     print(ts.to_datetime())
     self.assertAlmostEqual(datetime.now(JST).astimezone(tz=timezone.utc), ts.to_datetime(), delta=timedelta(0, 1))