solve empty query

This commit is contained in:
Daniel Tsvetkov 2019-03-14 10:35:19 -07:00
parent 1b93a7914a
commit c35a446150

9
tz.py
View File

@ -172,7 +172,12 @@ def parse_query(query):
"""
Parses the user query to the datetime, tz/loc parts
"""
to_query = ' '.join(query).split(" to ")
query = ' '.join(query)
query = query.strip()
if not query:
logger.critical("Use a query like <datetime-like> ['to' <timezone or location>]")
exit(1)
to_query = query.split(" to ")
logger.debug("to_query: {}".format(to_query))
if len(to_query) == 1:
# only datetime
@ -231,7 +236,7 @@ def solve_query(human_dt, human_tz_loc):
def format_result(result, fmt):
if result is None:
logger.critical("Could not s query")
logger.critical("Could not solve query")
exit(1)
logger.debug("Format: {}".format(fmt))
format_result = result.strftime(fmt)