diff --git a/src/economy/models.py b/src/economy/models.py index 29834678d..387a1cf51 100644 --- a/src/economy/models.py +++ b/src/economy/models.py @@ -1432,9 +1432,10 @@ def import_csv(self, csvreader): "24-08-2021";"24-08-2021";"f1a7b16b-27d3-432f-bca7-2e2229";"-59,85";"230.398,91" "24-08-2021";"24-08-2021";"63e93a24-073b-4ebb-8b0d-5a3072";"-1.221,05";"230.458,76" - The second date column is unused. Dates are in Europe/Copenhagen tz. + The second date column is unused. + Timezone for dates are defined in settings.TIME_ZONE. """ - cph = ZoneInfo("Europe/Copenhagen") + tz = ZoneInfo(settings.TIME_ZONE) create_count = 0 # Bank csv has the most recent lines first in the file, and the oldest last. # Read lines in reverse so we add the earliest transaction first, @@ -1445,7 +1446,7 @@ def import_csv(self, csvreader): # use update_or_create() so we can import a new CSV with the same transactions # but with updated descriptions, in case we fix a description in the bank tx, created = self.transactions.update_or_create( - date=datetime.strptime(row[0], "%d/%m/%Y").replace(tzinfo=cph), + date=datetime.strptime(row[0], "%d/%m/%Y").replace(tzinfo=tz), amount=Decimal(row[3].replace(".", "").replace(",", ".")), balance=Decimal(row[4].replace(".", "").replace(",", ".")), defaults={ diff --git a/src/economy/utils.py b/src/economy/utils.py index d5fc58ddf..bea2dbba8 100644 --- a/src/economy/utils.py +++ b/src/economy/utils.py @@ -45,7 +45,7 @@ from zoneinfo import ZoneInfo # we need the Danish timezone here and there -cph = ZoneInfo("Europe/Copenhagen") +cph = ZoneInfo(settings.TIME_ZONE) logger = logging.getLogger(f"bornhack.{__name__}") diff --git a/src/program/utils.py b/src/program/utils.py index f35627098..66145dbf5 100644 --- a/src/program/utils.py +++ b/src/program/utils.py @@ -144,7 +144,7 @@ def save_speaker_availability(form, obj) -> None: AvailabilityModel.objects.filter(**kwargs).delete() # all the entered data is in the users local TIME_ZONE, interpret it as such - tz = ZoneInfo("Europe/Copenhagen") + tz = ZoneInfo(settings.TIME_ZONE) # count availability form fields fieldcounter = 0 diff --git a/src/tokens/tests/test_views.py b/src/tokens/tests/test_views.py index 784fc3377..f29c37439 100644 --- a/src/tokens/tests/test_views.py +++ b/src/tokens/tests/test_views.py @@ -6,6 +6,7 @@ from datetime import datetime from bs4 import BeautifulSoup +from django.conf import settings from django.urls import reverse from tokens.models import Token @@ -29,7 +30,7 @@ def setUpTestData(cls) -> None: # first add users and other basics super().setUpTestData() - tz = ZoneInfo("Europe/Copenhagen") + tz = ZoneInfo(settings.TIME_ZONE) now = datetime.now(tz) year = now.year diff --git a/src/utils/bootstrap/base.py b/src/utils/bootstrap/base.py index 1c56b3c4b..67d7f72c0 100644 --- a/src/utils/bootstrap/base.py +++ b/src/utils/bootstrap/base.py @@ -101,7 +101,7 @@ from .functions import output_fake_md_description fake = Faker() -tz = ZoneInfo("Europe/Copenhagen") +tz = ZoneInfo(settings.TIME_ZONE) logger = logging.getLogger(f"bornhack.{__name__}")