Fixed #32727 -- Allowed spaces before time zone offset in parse_datetime().
This commit is contained in:
parent
fcb75651f9
commit
fff4870bfa
|
@ -23,7 +23,7 @@ datetime_re = _lazy_re_compile(
|
||||||
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})'
|
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})'
|
||||||
r'[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})'
|
r'[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})'
|
||||||
r'(?::(?P<second>\d{1,2})(?:[\.,](?P<microsecond>\d{1,6})\d{0,6})?)?'
|
r'(?::(?P<second>\d{1,2})(?:[\.,](?P<microsecond>\d{1,6})\d{0,6})?)?'
|
||||||
r'(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$'
|
r'\s*(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$'
|
||||||
)
|
)
|
||||||
|
|
||||||
standard_duration_re = _lazy_re_compile(
|
standard_duration_re = _lazy_re_compile(
|
||||||
|
|
|
@ -40,6 +40,9 @@ class DateParseTests(unittest.TestCase):
|
||||||
('2012-04-23T10:20:30.400+02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(120))),
|
('2012-04-23T10:20:30.400+02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(120))),
|
||||||
('2012-04-23T10:20:30.400-02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(-120))),
|
('2012-04-23T10:20:30.400-02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(-120))),
|
||||||
('2012-04-23T10:20:30,400-02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(-120))),
|
('2012-04-23T10:20:30,400-02', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(-120))),
|
||||||
|
('2012-04-23T10:20:30.400 +0230', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(150))),
|
||||||
|
('2012-04-23T10:20:30,400 +00', datetime(2012, 4, 23, 10, 20, 30, 400000, get_fixed_timezone(0))),
|
||||||
|
('2012-04-23T10:20:30 -02', datetime(2012, 4, 23, 10, 20, 30, 0, get_fixed_timezone(-120))),
|
||||||
)
|
)
|
||||||
for source, expected in valid_inputs:
|
for source, expected in valid_inputs:
|
||||||
with self.subTest(source=source):
|
with self.subTest(source=source):
|
||||||
|
|
Loading…
Reference in New Issue