tz added for parsing

This commit is contained in:
Daniel Tsvetkov 2020-02-11 12:49:26 +01:00
parent ddd352865a
commit 39527abc0a
2 changed files with 10 additions and 6 deletions

View File

@ -84,7 +84,7 @@ def handler_dateparser(dt_s: str) -> datetime:
def handler_time_in_parser(dt_s: str) -> datetime:
return query_to_format_result("now to {}".format(dt_s))
return query_to_format_result("now to {}".format(dt_s), None)
def handler_timezone(timezone_s: str):
@ -185,6 +185,7 @@ def dt_pretty(dt):
rv["locale_month_short"] = dt.strftime("%b")
rv["tz_name"] = dt.strftime("%Z")
rv["tz_offset"] = dt.strftime("%z")
rv["tz"] = resolve_timezone(dt.strftime("%z"))
rv["hh:mm"] = dt.strftime("%H:%M")
rv["locale_time"] = dt.strftime("%X")
rv["locale_date"] = dt.strftime("%x")
@ -295,7 +296,7 @@ def resolve_query(query):
if __name__ == "__main__":
# query = "time since 27 January 1992"
# query = "time in sofia"
query = ' '.join(sys.argv[1:])
result = resolve_query(query)
pretty_print_dict(result)

View File

@ -254,8 +254,11 @@ def find_from_offset(query):
continue
offset = splitted_query[1]
if ':' not in offset:
if len(offset) == 4:
hhs, mms = offset[0:2], offset[2:4]
else:
try:
hhs, mms = offset, "00"
hhs, mms = int(offset), "00"
except Exception:
continue
else: