Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_timestamp(self):
utc = build_utcoffset('UTC', timedelta(hours=0))
result = Ask._parse_timestamp('2017-07-08T07:38:00Z')
self.assertEqual(datetime(2017, 7, 8, 7, 38, 0, 0, utc), result)
result = Ask._parse_timestamp(1234567890)
self.assertEqual(datetime(2009, 2, 13, 23, 31, 30), result)
with self.assertRaises(ValueError):
Ask._parse_timestamp(None)
#hhmmss±hhmm
#hh:mm±hhmm
#hhmm±hhmm
#hh±hhmm
#hh:mm:ss±hh
#hhmmss±hh
#hh:mm±hh
#hhmm±hh
#hh±hh
(timestr, tzstr) = _split_tz(isotimestr)
if tzstr == None:
return _parse_time_naive(timestr)
elif tzstr == 'Z':
return _parse_time_naive(timestr).replace(tzinfo=build_utcoffset('UTC', datetime.timedelta(hours=0)))
else:
return _parse_time_naive(timestr).replace(tzinfo=parse_timezone(tzstr))