From 640496deb262349101567de12d2476cbfe5065b3 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 14 Oct 2017 11:25:46 +0200 Subject: timezone.now() retourne l’heure UTC, ce qui empêche la mise à jour de la semaine prochaine le samedi à minuit. Remplacement de ces appels par une fonction qui retourne la bonne heure dans le bon fuseau horaire. --- management/commands/timetables.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'management') diff --git a/management/commands/timetables.py b/management/commands/timetables.py index a152f9e..35fb26e 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -21,7 +21,7 @@ from django.db.models import Min from django.utils import timezone from edt.models import Course, Timetable -from edt.utils import get_week +from edt.utils import get_week, tz_now from ._private import delete_courses_in_week, get_events, get_update_date, get_weeks, get_xml @transaction.atomic @@ -32,7 +32,7 @@ def process_timetable_week(timetable, soup, weeks_in_soup, force, year=None, wee if force: today = begin else: - today = timezone.make_aware(datetime.datetime.now()) + today = tz_now() # On récupère la mise à jour la plus ancienne dans les cours de l’emploi du temps # commençant à partir de maintenant @@ -107,16 +107,16 @@ class Command(BaseCommand): if options["all"]: weeks = None elif options["week"] is None: - _, week, day = timezone.now().isocalendar() + _, 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() weeks = [week] else: weeks = options["week"] if not options["all"]: if options["year"] is None and year is None: - year = timezone.now().year + year = tz_now().year elif year is None: year = options["year"][0] -- cgit v1.2.1