aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils.py b/utils.py
index 9f0a6b5..839d8bc 100644
--- a/utils.py
+++ b/utils.py
@@ -18,9 +18,11 @@ import re
from django.utils import timezone
+
def get_current_week():
return tz_now().isocalendar()[:2]
+
def get_current_or_next_week():
year, week, day = tz_now().isocalendar()
if day >= 6:
@@ -28,6 +30,7 @@ def get_current_or_next_week():
return year, week
+
def get_week(year, week):
start = timezone.make_aware(datetime.datetime.strptime(
"{0}-W{1}-1".format(year, week), "%Y-W%W-%w"))
@@ -35,6 +38,7 @@ def get_week(year, week):
return start, end
+
def group_courses(courses):
grouped_courses = []
for i, course in enumerate(courses):
@@ -45,6 +49,7 @@ def group_courses(courses):
return grouped_courses
+
def parse_group(name):
# Explication de la regex
#
@@ -66,7 +71,8 @@ def parse_group(name):
parts = search.groups()
- # On retourne la section (parts[0]), le semestre (parts[2]) et le groupe (parts[5])
+ # On retourne la section (parts[0]), le semestre (parts[2]) et le
+ # groupe (parts[5])
if parts[2] is not None:
return parts[0], int(parts[2]), parts[5]
else:
@@ -75,6 +81,7 @@ def parse_group(name):
# une erreur.
return parts[0], None, parts[5]
+
def tz_now():
"""Retourne la date et l’heure avec le bon fuseau horaire"""
return timezone.make_aware(datetime.datetime.now())