Use non-localized date parsing to fix #1838
This commit is contained in:
parent
51bff6cf6a
commit
1a6cb48ea0
@ -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/
|
||||
|
Loading…
x
Reference in New Issue
Block a user