Closes bpo-31800: Support for colon when parsing time offsets (#4015)

Add support to strptime to parse time offsets with a colon between the hour and the minutes.
This commit is contained in:
Mario Corchero 2017-10-26 01:35:41 +01:00 committed by Alexander Belopolsky
parent 0f261583ba
commit 32318930da
5 changed files with 84 additions and 13 deletions

View file

@ -2147,6 +2147,10 @@ class TestDateTime(TestDate):
strptime = self.theclass.strptime
self.assertEqual(strptime("+0002", "%z").utcoffset(), 2 * MINUTE)
self.assertEqual(strptime("-0002", "%z").utcoffset(), -2 * MINUTE)
self.assertEqual(
strptime("-00:02:01.000003", "%z").utcoffset(),
-timedelta(minutes=2, seconds=1, microseconds=3)
)
# Only local timezone and UTC are supported
for tzseconds, tzname in ((0, 'UTC'), (0, 'GMT'),
(-_time.timezone, _time.tzname[0])):