Beispiel #1
0
 def test_parse_datetime(self):
   exv1 = datetime(2016, 2, 1, 8, 32, 15)
   exv2 = datetime(2016, 2, 1, 8, 32, 15, tzinfo=timezone.utc)
   exv3 = datetime(2016, 2, 1, 8, 32, 15, tzinfo=timezone(timedelta(hours=-7)))
   exv4 = datetime(2016, 2, 1, 8, 32, 15, tzinfo=timezone(timedelta(hours=5)))
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15"), exv1)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15Z"), exv2)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15+0000"), exv2)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15-0700"), exv3)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15-07"), exv3)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15+0500"), exv4)
   self.assertEqual(udate.parse_datetime("2016-02-01 08:32:15+05"), exv4)
   self.assertEqual(udate.parse_datetime(exv1), exv1)
Beispiel #2
0
def to_datetime(val, fmt=None):
  return date.parse_datetime(val, fmt)