Commit 21b2e88c authored by fred's avatar fred
Browse files

adjust day for program starting after midnight and before dawn

parent 88c7ef7f
......@@ -97,6 +97,8 @@ def period_program(
):
from .models import Absence, Diffusion, Nonstop, Schedule, SoundFile, WeekdayMixin
dawn = time(Schedule.DAY_HOUR_START, Schedule.DAY_MINUTE_START)
diffusions = (
Diffusion.objects.select_related().filter(datetime__range=(date_start, date_end)).order_by('datetime')
)
......@@ -140,6 +142,8 @@ def period_program(
# on Sundays we can have Sunday->Monday night programming, and
# we need to get them on the right date.
schedule.datetime += timedelta(days=7)
if schedule.datetime.time() < dawn:
schedule.datetime += timedelta(days=1)
program.extend(day_schedules)
current_date += timedelta(days=1)
......@@ -233,7 +237,6 @@ def period_program(
# last step is adding nonstop zones between slots
nonstops = list(Nonstop.objects.all().order_by('start'))
nonstops = [x for x in nonstops if x.start != x.end]
dawn = time(Schedule.DAY_HOUR_START, Schedule.DAY_MINUTE_START)
try:
first_of_the_day = [x for x in nonstops if x.start <= dawn][-1]
nonstops = nonstops[nonstops.index(first_of_the_day) :] + nonstops[: nonstops.index(first_of_the_day)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment