Commit d88e3215 authored by Jérome Perrin's avatar Jérome Perrin

XXX: proto.py use freezegun, as RELATIVE_BASE seem to cause issues

parent 119f5dbb
......@@ -6,6 +6,7 @@ import time
import dateparser
import pytz
import freezegun
# this is golang's time.RFC3339
rfc3339_format = "%Y-%m-%dT%H:%M:%SZ"
......@@ -36,11 +37,14 @@ time.tzset()
# process relative time
if args.relative_time_base and args.relative_time_base != "now":
dateparser_settings["RELATIVE_BASE"] = datetime.datetime.strptime(
args.relative_time_base, rfc3339_format
).replace(
# dateparsers' has a RELATIVE_BASE option for this, but this does not work well,
# this triggers some TypeError internally, so use freezetime to change
# time base.
freezegun.freeze_time(
datetime.datetime.strptime(
args.relative_time_base, rfc3339_format).replace(
tzinfo=pytz.utc # the Z in our format means UTC
).astimezone(pytz.timezone(args.timezone))
).astimezone(pytz.timezone(args.timezone))).start()
with open(args.formats, "r") as f:
for line in f:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment