From ea18b836283a2d07edaf628ca1e07ea96a1f9a07 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Tue, 11 Feb 2020 15:47:05 +0100 Subject: [PATCH] default is not utc --- src/tww/tokenizer.py | 12 +++--------- src/tww/tww.py | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/tww/tokenizer.py b/src/tww/tokenizer.py index 212ff12..9e01506 100644 --- a/src/tww/tokenizer.py +++ b/src/tww/tokenizer.py @@ -80,10 +80,6 @@ def handler_generic_parser(dt_s: str) -> datetime: return query_to_format_result(dt_s, None) -def handler_dateparser(dt_s: str) -> datetime: - return dateparser_parse_dt(dt_s) - - def handler_time_in_parser(dt_s: str) -> datetime: return query_to_format_result("now to {}".format(dt_s), None) @@ -113,7 +109,6 @@ regex_handlers = [ (r_time_in, handler_time_in_parser, QUERY_TYPE_DT), (r_timezone, handler_timezone, QUERY_TYPE_TZ), (r_timezone_2, handler_timezone, QUERY_TYPE_TZ), - (r_generic, handler_dateparser, QUERY_TYPE_DT), (r_generic, handler_generic_parser, QUERY_TYPE_DT), ] @@ -421,10 +416,9 @@ def resolve_query(query): if __name__ == "__main__": - query = "" - custom_locale = "български език" - # custom_locale = "" + query = ' '.join(sys.argv[1:]) + # query = "now in india" + custom_locale = "" custom_locale = resolve_locale(custom_locale) - # 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 9fea040..92375b0 100644 --- a/src/tww/tww.py +++ b/src/tww/tww.py @@ -480,7 +480,7 @@ def dateparser_parse_dt(s: str): if not parsed: return None if parsed.tzinfo is None: - parsed = parsed.replace(tzinfo=pytz.timezone("utc")) + parsed = parsed.replace(tzinfo=tzinfo_from_offset(get_local_tz_offset())[0]) return parsed