Skip to content

Commit 9d6803a

Browse files
rachele-collinakx
rachele-collin
authored andcommitted
Parse string date times indepentent of time zone
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
1 parent 90739af commit 9d6803a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

babel/messages/catalog.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"""
1111

1212
import re
13-
import time
1413

1514
from cgi import parse_header
1615
from collections import OrderedDict
@@ -43,9 +42,7 @@
4342
def _parse_datetime_header(value):
4443
match = re.match(r'^(?P<datetime>.*?)(?P<tzoffset>[+-]\d{4})?$', value)
4544

46-
tt = time.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
47-
ts = time.mktime(tt)
48-
dt = datetime.fromtimestamp(ts)
45+
dt = datetime.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
4946

5047
# Separate the offset into a sign component, hours, and # minutes
5148
tzoffset = match.group('tzoffset')

0 commit comments

Comments
 (0)