Use non-localized date parsing to fix #1838

This commit is contained in:
Christof Kaufmann 2020-02-25 11:59:31 +01:00
parent 51bff6cf6a
commit 1a6cb48ea0

View File

@ -4,6 +4,7 @@
from fontTools.misc.py23 import *
import os
import time
from datetime import datetime, timezone
import calendar
@ -44,7 +45,12 @@ def timestampToString(value):
return asctime(time.gmtime(max(0, value + epoch_diff)))
def timestampFromString(value):
return calendar.timegm(time.strptime(value)) - epoch_diff
wkday, mnth = value[:7].split()
t = datetime.strptime(value[7:], ' %d %H:%M:%S %Y')
t = t.replace(month=MONTHNAMES.index(mnth), tzinfo=timezone.utc)
wkday_idx = DAYNAMES.index(wkday)
assert t.weekday() == wkday_idx, '"' + value + '" has inconsistent weekday'
return int(t.timestamp()) - epoch_diff
def timestampNow():
# https://reproducible-builds.org/specs/source-date-epoch/