A program that spans Saturday night to Sunday cannot be scheduled. The error is 'Program must start before it finishes' or something similar.
The easy fix to this problem was to enter the show directly into the station_schedule table with an endtime of 10080 (midnight on Sunday morning).
But this causes another problem: the program's schedule does not display the day of the week, only the hours of the show (eg. 11pm - 12am, and not Saturday 11pm - 12am). The fix was to add Sunday to the bottom of the array at line 70 in dayhour.inc, so Sunday is now both at the top and bottom of the array.
Now this solves both problems above, but brings up a minor annoyance. The schedule now shows Sunday twice in the table.
I have only spent about 30 minutes delving into the issue, and there's probably a more elegant fix (I'll spend more time on it tomorrow). But I'm reporting this just in case there's already a known solution that's better than my hack :-)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | sundayfix.patch | 2.3 KB | cybertoast |
| #3 | sundayfix.tgz | 5.33 KB | cybertoast |
Comments
Comment #1
drewish commentedthat's really by design. it's not the prettiest way to do it but you can just have it schedule for two times, one on sunday and one on saturday.
Comment #2
cybertoast commentedActually this solution won't work. A show that goes from Sat 11pm to Sun 1am would have to be from Sat 22.00 to Sun 00.00. But this cannot be done since Sun = 0 and Sat = 6 (I get the error "The program must start before it finishes.").
I'm not sure if others are interested in this fix, but once I get it working I'll let you know. Basically here's the solution I'm using (and would like to have added into the main codebase):
1. Change dayhour.inc, line 70:
Add Sunday to the bottom of the array. This adds a second Sunday to the list of days when adding a new scheduled program. You just have to remember to select the bottom one when a show starts on Sat and ends on Sun. This could be done using javascript or some other code-fix, but I think this is pretty easy.
2. Change schedule/schedule.inc, line 49 and line 297:
The for() loop must do $i <= 7 (instead of $i < 7). This makes sure to find shows at the bottom of the week.
This should suffice for splitting the entries into 2 (Sat to midnight, then sunday from midnight). But to do a more thorough fix, I did the following:
3. When listing shows for Sunday, shows at the bottom of the week won't show up. The fix is in schedule_schedule_day_page() (schedule.inc, line 380). If we're trying to display all the programs for Sunday, we push the programs from the "bottom" Sunday into the array before we format the schedule for output.
$schedule = station_schedule_schedule_load_day($day);
if ($day == 0) {
$schedule_extra = station_schedule_schedule_load_day(7);
$schedule = array_merge($schedule_extra, $schedule);
}
This solves the "problem" as far as I can tell. If there is a better solution, please let me know. I'd really like to have this feature added to the main codebase (mainly so i don't have to deal with selective patching with future releases).
Thanks much.
Comment #3
cybertoast commentedAAARGH! My long posting just got truncated rather blithely! Anyway, the diffs from the 11/21 (v1.17.4.1) release are below. I've also attached the new source files in the tarball.
A. Diff for dayhour.inc:
78,79c78
< 'Saturday',
< 'Sunday'
---
> 'Saturday'
B. Diff for schedule/schedule.inc
16,18d15
< if ($day == 7) {
< print_r("start $start, finish $finish
");
< }
49c46
< for ($i = 0; $i <= 7; $i++) { // Need to <= to deal with bottom Sunday
---
> for ($i = 0; $i < 7; $i++) {
297c294
< for ($i = 0; $i <= 7; $i++) { // Need to <= to deal with bottom Sunday
---
> for ($i = 0; $i < 7; $i++) {
381,385d377
< // In order to deal with shows spanning Sat and Sun (bottom Sunday)
< if ($day == 0) {
< $schedule_extra = station_schedule_schedule_load_day(7);
< $schedule = array_merge($schedule_extra, $schedule);
< }
388c380
< $output .= $dayschedule;
---
> $output = $dayschedule;
Comment #4
drewish commentedcybertoast, the current way of making it work would be to use saturday 24:00, not sunday 0:00. please post a proper patch, see http://drupal.org/patch for instructions.
Comment #5
cybertoast commentedAh, sorry about that. Yeah, the 24:00 solution works. Didn't think to try that! Anyway, the patch file is attached. Cheers.
Comment #6
drewish commentedsince that was working for you, i'm going to mark this as won't fix.