Fix when parsing tz offsets microseconds shorter than 6 (#4781)

As the remainder was directly parsed as an int, strings like
.600 were parsed as 600 microseconds rather than milliseconds.
This commit is contained in:
Mario Corchero 2018-01-09 21:37:26 +00:00 committed by Alexander Belopolsky
parent d4864c61e3
commit f80c0ca133
2 changed files with 7 additions and 1 deletions

View file

@ -345,6 +345,9 @@ class StrptimeTests(unittest.TestCase):
(*_, offset), _, offset_fraction = _strptime._strptime("-01:30:30.000001", "%z")
self.assertEqual(offset, -(one_hour + half_hour + half_minute))
self.assertEqual(offset_fraction, -1)
(*_, offset), _, offset_fraction = _strptime._strptime("+01:30:30.001", "%z")
self.assertEqual(offset, one_hour + half_hour + half_minute)
self.assertEqual(offset_fraction, 1000)
(*_, offset), _, offset_fraction = _strptime._strptime("Z", "%z")
self.assertEqual(offset, 0)
self.assertEqual(offset_fraction, 0)