From e7864eeaa1b0001c9f686e122fd9f967fa03f8f5 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 13 Nov 2024 16:10:27 +0100 Subject: [PATCH] fix: correct date calculation logic in update_database Ensure proper date subtraction by converting `date_zero` to a date object before calculating the `amount`. This prevents potential errors in date operations and ensures accurate date range handling. --- app/charts/synchronous.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/charts/synchronous.py b/app/charts/synchronous.py index c5ebb2e..c717ad3 100644 --- a/app/charts/synchronous.py +++ b/app/charts/synchronous.py @@ -521,12 +521,12 @@ def update_database(date_from=None, date_to=None): if not (date_from) or not (date_to): date_to = date.today() date_from = date_to - timedelta(5) - amount = date_from - datetime.datetime.strptime(date_zero, "%Y-%m-%d") + amount = date_from - datetime.datetime.strptime(date_zero, "%Y-%m-%d").date() else: print(str(date_from) + " to " + str(date_to)) date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d") date_to = datetime.datetime.strptime(date_to, "%Y-%m-%d") - amount = date_from - datetime.datetime.strptime(date_zero, "%Y-%m-%d") + amount = date_from - datetime.datetime.strptime(date_zero, "%Y-%m-%d").date() count = 0 date_aux = date_from