]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
rewrite regexp parsing
authorAlex Morega <alex@grep.ro>
Mon, 6 Jan 2014 19:43:33 +0000 (21:43 +0200)
committerAlex Morega <alex@grep.ro>
Mon, 6 Jan 2014 19:43:33 +0000 (21:43 +0200)
babel/messages/catalog.py

index 82c08c881e7a6244fca7523d86efe678fec976b6..756d64cceebe26d64e8e267f605760cf5c266c13 100644 (file)
@@ -41,12 +41,13 @@ PYTHON_FORMAT = re.compile(r'''(?x)
 
 
 def _parse_datetime_header(value):
-    value, tzoffset, _ = re.split('([+-]\d{4})$', value, 1)
+    match = re.match(r'^(?P<datetime>.*)(?P<tzoffset>[+-]\d{4})$', value)
 
-    tt = time.strptime(value, '%Y-%m-%d %H:%M')
+    tt = time.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
     ts = time.mktime(tt)
 
     # Separate the offset into a sign component, hours, and # minutes
+    tzoffset = match.group('tzoffset')
     plus_minus_s, rest = tzoffset[0], tzoffset[1:]
     hours_offset_s, mins_offset_s = rest[:2], rest[2:]