aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/utils.py b/utils.py
index bd337e4..28a1ba2 100644
--- a/utils.py
+++ b/utils.py
@@ -19,12 +19,12 @@ import re
from django.utils import timezone
def get_current_week():
- return timezone.now().isocalendar()[:2]
+ return tz_now().isocalendar()[:2]
def get_current_or_next_week():
- year, week, day = timezone.now().isocalendar()
+ year, week, day = tz_now().isocalendar()
if day >= 6:
- year, week, _ = (timezone.now() + datetime.timedelta(weeks=1)).isocalendar()
+ year, week, _ = (tz_now() + datetime.timedelta(weeks=1)).isocalendar()
return year, week
@@ -74,3 +74,7 @@ def parse_group(name):
return parts[0], parts[5], parts[6], None
elif parts[7] is not None: # Groupe de TP
return parts[0], parts[8], parts[9], parts[10]
+
+def tz_now():
+ """Retourne la date et l’heure avec le bon fuseau horaire"""
+ return timezone.make_aware(datetime.datetime.now())