ajout d'un toggle pour permission d'upload des documents dans admin pannel
CI - Security, Lint & Tests / validate (push) Failing after 1m3s
CI - Security, Lint & Tests / validate (push) Failing after 1m3s
ajout de compteur d'heure disponible ajout du calendrier de dispo dans les profils publics
This commit is contained in:
@@ -58,3 +58,39 @@ def day_name(day_of_week):
|
||||
if 0 <= day_of_week < len(DAY_NAMES):
|
||||
return DAY_NAMES[day_of_week]
|
||||
return f'Day {day_of_week}'
|
||||
|
||||
|
||||
def slot_duration_minutes(start_time, end_time):
|
||||
"""Minutes a slot spans, wrapping past midnight like slot_end does.
|
||||
|
||||
Works on SQLite where ``Time`` columns are stored as text — the
|
||||
arithmetic stays in pure Python so it is portable across databases.
|
||||
|
||||
Args:
|
||||
start_time: A ``datetime.time``.
|
||||
end_time: A ``datetime.time`` (may be earlier if the slot wraps
|
||||
past midnight).
|
||||
|
||||
Returns:
|
||||
int: Duration in whole minutes.
|
||||
"""
|
||||
anchor = date_cls(2000, 1, 1)
|
||||
start_dt = datetime.combine(anchor, start_time)
|
||||
end_dt = datetime.combine(anchor, end_time)
|
||||
if end_dt <= start_dt:
|
||||
end_dt += timedelta(days=1)
|
||||
return int((end_dt - start_dt).total_seconds() // 60)
|
||||
|
||||
|
||||
def total_hours(slots):
|
||||
"""Aggregate slot durations into a single float, rounded to one decimal.
|
||||
|
||||
Args:
|
||||
slots: Iterable of objects with ``start_time`` and ``end_time``
|
||||
attributes (``PlayerDisponibility`` or ``CoachAvailability``).
|
||||
|
||||
Returns:
|
||||
float: Total hours across all slots, e.g. ``8.5``.
|
||||
"""
|
||||
total_minutes = sum(slot_duration_minutes(s.start_time, s.end_time) for s in slots)
|
||||
return round(total_minutes / 60, 1)
|
||||
|
||||
Reference in New Issue
Block a user