fix: correct date calculation logic in update_database
Some checks are pending
Docker / build (push) Waiting to run

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.
This commit is contained in:
Kumi 2024-11-13 16:10:27 +01:00
parent 003fa03811
commit e7864eeaa1
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -521,12 +521,12 @@ def update_database(date_from=None, date_to=None):
if not (date_from) or not (date_to): if not (date_from) or not (date_to):
date_to = date.today() date_to = date.today()
date_from = date_to - timedelta(5) 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: else:
print(str(date_from) + " to " + str(date_to)) print(str(date_from) + " to " + str(date_to))
date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d") date_from = datetime.datetime.strptime(date_from, "%Y-%m-%d")
date_to = datetime.datetime.strptime(date_to, "%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 count = 0
date_aux = date_from date_aux = date_from