tz added for parsing
This commit is contained in:
parent
ddd352865a
commit
39527abc0a
@ -84,7 +84,7 @@ def handler_dateparser(dt_s: str) -> datetime:
|
|||||||
|
|
||||||
|
|
||||||
def handler_time_in_parser(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):
|
def handler_timezone(timezone_s: str):
|
||||||
@ -185,6 +185,7 @@ def dt_pretty(dt):
|
|||||||
rv["locale_month_short"] = dt.strftime("%b")
|
rv["locale_month_short"] = dt.strftime("%b")
|
||||||
rv["tz_name"] = dt.strftime("%Z")
|
rv["tz_name"] = dt.strftime("%Z")
|
||||||
rv["tz_offset"] = dt.strftime("%z")
|
rv["tz_offset"] = dt.strftime("%z")
|
||||||
|
rv["tz"] = resolve_timezone(dt.strftime("%z"))
|
||||||
rv["hh:mm"] = dt.strftime("%H:%M")
|
rv["hh:mm"] = dt.strftime("%H:%M")
|
||||||
rv["locale_time"] = dt.strftime("%X")
|
rv["locale_time"] = dt.strftime("%X")
|
||||||
rv["locale_date"] = dt.strftime("%x")
|
rv["locale_date"] = dt.strftime("%x")
|
||||||
@ -295,7 +296,7 @@ def resolve_query(query):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# query = "time since 27 January 1992"
|
# query = "time in sofia"
|
||||||
query = ' '.join(sys.argv[1:])
|
query = ' '.join(sys.argv[1:])
|
||||||
result = resolve_query(query)
|
result = resolve_query(query)
|
||||||
pretty_print_dict(result)
|
pretty_print_dict(result)
|
||||||
|
@ -254,10 +254,13 @@ def find_from_offset(query):
|
|||||||
continue
|
continue
|
||||||
offset = splitted_query[1]
|
offset = splitted_query[1]
|
||||||
if ':' not in offset:
|
if ':' not in offset:
|
||||||
try:
|
if len(offset) == 4:
|
||||||
hhs, mms = offset, "00"
|
hhs, mms = offset[0:2], offset[2:4]
|
||||||
except Exception:
|
else:
|
||||||
continue
|
try:
|
||||||
|
hhs, mms = int(offset), "00"
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
splitted_offset = offset.split(':')
|
splitted_offset = offset.split(':')
|
||||||
if len(splitted_offset) != 2:
|
if len(splitted_offset) != 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user