solve empty query
This commit is contained in:
parent
1b93a7914a
commit
c35a446150
9
tz.py
9
tz.py
@ -172,7 +172,12 @@ def parse_query(query):
|
|||||||
"""
|
"""
|
||||||
Parses the user query to the datetime, tz/loc parts
|
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))
|
logger.debug("to_query: {}".format(to_query))
|
||||||
if len(to_query) == 1:
|
if len(to_query) == 1:
|
||||||
# only datetime
|
# only datetime
|
||||||
@ -231,7 +236,7 @@ def solve_query(human_dt, human_tz_loc):
|
|||||||
|
|
||||||
def format_result(result, fmt):
|
def format_result(result, fmt):
|
||||||
if result is None:
|
if result is None:
|
||||||
logger.critical("Could not s query")
|
logger.critical("Could not solve query")
|
||||||
exit(1)
|
exit(1)
|
||||||
logger.debug("Format: {}".format(fmt))
|
logger.debug("Format: {}".format(fmt))
|
||||||
format_result = result.strftime(fmt)
|
format_result = result.strftime(fmt)
|
||||||
|
Loading…
Reference in New Issue
Block a user