forked from DGNum/gestioCOF
Plus de timezones
This commit is contained in:
parent
6767ba8e8c
commit
78ad4402b0
1 changed files with 2 additions and 4 deletions
|
@ -1,19 +1,17 @@
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
|
|
||||||
import pytz
|
|
||||||
from dateutil.parser import parse as dateutil_parse
|
from dateutil.parser import parse as dateutil_parse
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
KFET_WAKES_UP_AT = time(7, 0)
|
KFET_WAKES_UP_AT = time(5, 0) # La K-Fêt ouvre à 5h (UTC) du matin
|
||||||
|
|
||||||
|
|
||||||
def kfet_day(year, month, day, start_at=KFET_WAKES_UP_AT):
|
def kfet_day(year, month, day, start_at=KFET_WAKES_UP_AT):
|
||||||
"""Étant donné une date, renvoie un objet `datetime`
|
"""Étant donné une date, renvoie un objet `datetime`
|
||||||
correspondant au début du 'jour K-Fêt' correspondant."""
|
correspondant au début du 'jour K-Fêt' correspondant."""
|
||||||
naive = datetime.combine(date(year, month, day), start_at)
|
return datetime.combine(date(year, month, day), start_at)
|
||||||
return pytz.timezone("Europe/Paris").localize(naive, is_dst=None)
|
|
||||||
|
|
||||||
|
|
||||||
def to_kfet_day(dt, start_at=KFET_WAKES_UP_AT):
|
def to_kfet_day(dt, start_at=KFET_WAKES_UP_AT):
|
||||||
|
|
Loading…
Reference in a new issue