]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Parse string date times indepentent of time zone
authorrachele-collin <63007243+rachele-collin@users.noreply.github.com>
Wed, 1 Apr 2020 16:05:11 +0000 (18:05 +0200)
committerAarni Koskela <akx@iki.fi>
Fri, 28 Jan 2022 15:15:52 +0000 (17:15 +0200)
Parsing a date time string (such as for ``POT-Creation-Date`` or
``PO-Revision-Date``) as UTC time, in particular independent of the
local time zone.

Closes: #700
babel/messages/catalog.py

index e516fd8ca491ff29d05a1dbe4f46136bfd90f16a..342f7377bf2e16716a5e49c4f63c1c8eb6fdfa17 100644 (file)
@@ -10,7 +10,6 @@
 """
 
 import re
-import time
 
 from cgi import parse_header
 from collections import OrderedDict
@@ -43,9 +42,7 @@ PYTHON_FORMAT = re.compile(r'''
 def _parse_datetime_header(value):
     match = re.match(r'^(?P<datetime>.*?)(?P<tzoffset>[+-]\d{4})?$', value)
 
-    tt = time.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
-    ts = time.mktime(tt)
-    dt = datetime.fromtimestamp(ts)
+    dt = datetime.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
 
     # Separate the offset into a sign component, hours, and # minutes
     tzoffset = match.group('tzoffset')