Skip to content

Commit

Permalink
Parse string date times indepentent of time zone
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rachele-collin authored and akx committed Jan 28, 2022
1 parent 90739af commit 9d6803a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions babel/messages/catalog.py
Expand Up @@ -10,7 +10,6 @@
"""

import re
import time

from cgi import parse_header
from collections import OrderedDict
Expand Down Expand Up @@ -43,9 +42,7 @@
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')
Expand Down

0 comments on commit 9d6803a

Please sign in to comment.