summaryrefslogtreecommitdiff
path: root/django/utils/dateparse.py
diff options
context:
space:
mode:
authorRichard Eames <reames@asymmetricventures.com>2014-06-12 10:58:50 -0600
committerRichard Eames <reames@asymmetricventures.com>2014-06-12 10:58:50 -0600
commit7beaeeed2b99ec120486ee53e1eb7f1fe2515b9c (patch)
tree072ca3deba0902058a8a95c3576f0abbd82298be /django/utils/dateparse.py
parentbcc3d2b9788cbee5f3fc654c1b0e8324294d8f02 (diff)
Fixed #22814 -- Allowed ISO-8601 [+-]hh timezone format in parse_datetime
Diffstat (limited to 'django/utils/dateparse.py')
-rw-r--r--django/utils/dateparse.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py
index f2c079023f..cb45a2760b 100644
--- a/django/utils/dateparse.py
+++ b/django/utils/dateparse.py
@@ -24,7 +24,7 @@ datetime_re = re.compile(
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'(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?'
- r'(?P<tzinfo>Z|[+-]\d{2}:?\d{2})?$'
+ r'(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$'
)
@@ -76,7 +76,8 @@ def parse_datetime(value):
if tzinfo == 'Z':
tzinfo = utc
elif tzinfo is not None:
- offset = 60 * int(tzinfo[1:3]) + int(tzinfo[-2:])
+ offset_mins = int(tzinfo[-2:]) if len(tzinfo) > 3 else 0
+ offset = 60 * int(tzinfo[1:3]) + offset_mins
if tzinfo[0] == '-':
offset = -offset
tzinfo = get_fixed_timezone(offset)