diff --git a/src/tww/tokenizer.py b/src/tww/tokenizer.py index c3d0c6a..e52ebc1 100644 --- a/src/tww/tokenizer.py +++ b/src/tww/tokenizer.py @@ -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) diff --git a/src/tww/tww.py b/src/tww/tww.py index 45d86dd..08b2253 100644 --- a/src/tww/tww.py +++ b/src/tww/tww.py @@ -254,10 +254,13 @@ def find_from_offset(query): continue offset = splitted_query[1] if ':' not in offset: - try: - hhs, mms = offset, "00" - except Exception: - continue + if len(offset) == 4: + hhs, mms = offset[0:2], offset[2:4] + else: + try: + hhs, mms = int(offset), "00" + except Exception: + continue else: splitted_offset = offset.split(':') if len(splitted_offset) != 2: