From 10389e8da7bcfabf75560b7f54aa1b9c410bc0c6 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Fri, 3 Nov 2023 09:44:16 +0100 Subject: [PATCH] Fix start_stop() when both given --- web/run.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/web/run.py b/web/run.py index 6092549..a26e78b 100755 --- a/web/run.py +++ b/web/run.py @@ -1082,26 +1082,32 @@ def get_input_slug_from_query(inp=None): return input_slug -def get_default_sta_sto(sta=None, sto=None): +def get_default_sta_sto(sta_str=None, sto_str=None): - # TODO : maybe get from configuration relative_after = config['defaults']['relative_after'] relative_before = config['defaults']['relative_before'] before = relativedelta(months=relative_before) after = relativedelta(months=relative_after) - if sta is None and sto is None: + if sta_str is None and sto_str is None: today = datetime.datetime.now().replace(hour=0, minute=0, second=0) sta_date = today - before sto_date = today + after - if sta is None and sto is not None: - sto_date = dateparser.isoparse(sto) + elif sta_str is not None and sto_str is None: + sta_date = dateparser.isoparse(sta_str) + sto_date = sta_date + after + + elif sta_str is None and sto_str is not None: + sto_date = dateparser.isoparse(sto_str) sta_date = sto_date - before - if sta is not None and sto is None: - sta_date = dateparser.isoparse(sta) - sto_date = sta_date + after + elif sta_str is not None and sto_str is not None: + sto_date = dateparser.isoparse(sto_str) + sta_date = dateparser.isoparse(sta_str) + + else: + raise Exception("IMPOSSIBLE") return sta_date, sto_date -- libgit2 0.21.2