Under admin/settings/date-time there's a setting for when the week starts.
It would be good if the Schedule pages took this into account -- both the order of the tabs, and the display of the full week grid.

This shouldn't affect the internal storage of when programs are, as otherwise if you change the site setting all your programs would be on the wrong days -- it's purely a display thing.

Comments

drewish’s picture

yeah that would be good. then all you non-US people would be happy.

shawnc’s picture

I think I'm looking for a similar fix as joachim...

My reason is that our station has a show that starts at 10pm on Saturday, and runs until 2am on Sunday. The problem I encounter is that the Schedule module won't let me add this show, telling me that the show must "start before it ends". Well yes, of course it must. =P In my 'global' settings within Drupal, my week starts on a Monday. If my station schedule could start on a Monday, that would be great, since 12 midnight Monday morning starts a new block of programming.

Mind you, this would solve my problem, but it doesn't address the real issue. The real issue is that the schedule module needs to have the foresight to recognize that real-world radio station schedules are in a constant weekly loop, and programs may run from the end of Day 1 into the wee hours of Day 2.

drewish’s picture

shawnc, no arguments, the schedule is dumb. i've got plenty of ideas to fix it but not enough time. any help on this small fix would be much appreciated.

shawnc’s picture

Thanks for your swift reply. We're making a great deal of progress in other directions using the Station module, so this isn't holding us back by any means (though, it would be great to see it fixed). =)

drewish’s picture

after looking at the relevant code i think i could adjust the ordering of the days on the weekly schedule but it wouldn't solve shawnc's problem. as has been discussed, his is actually related to the limited way that the schedule is stored on a weekly basis.

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.63 KB

Here's a patch...

- sets the weights of the day sections on the schedule node
- makes a rearranged copy of the schedule array prior to it being turned into a table, both for viewing and editing the schedule.

joachim’s picture

Just realized that I haven't fixed the drop-downs you get to add or edit a schedule item.
Drewish, do you think it needs handling as well?

Oh, and shawnc -- I'll try to look at letting a schedule item wrap round the end of the week for another patch later & file it as a separate issue.

drewish’s picture

joachim, it might be best to set the order in dayhour.inc::station_day_name() so that it's correct everywhere.

joachim’s picture

I don't think it's possible to set the order everywhere just by changing dayhour.inc::station_day_name().
For example, in schedule.module at line 818, the order in which columns are put into the table comes from $node->schedule, so I've got to reorder of that array before the foreach loops on it.

However, ALSO setting the order in dayhour.inc::station_day_name() means that the drop-downs are right :)

I can't make a patch for dayhour.inc, I'm afraid -- CVS gives me the error 'cvs [update aborted]: tag `*' must start with a letter' which is greek to me.
Here's my altered version of station_day_name, in addition to the earlier patch:

function station_day_name($day = NULL) {
  static $days;
  
  if (!isset($days)) {
    $daysplain = array(
      0 => t('Sunday'),
      t('Monday'),
      t('Tuesday'),
      t('Wednesday'),
      t('Thursday'),
      t('Friday'),
      t('Saturday')
    );
    $dayoffset = variable_get('date_first_day', 0);
    for ($i=0; $i<7; $i++)
    {
      $days[($i + $dayoffset) %7] = $daysplain[($i + $dayoffset) %7];
    }
  }
  
  if ($day === NULL) {   
    return $days;
  }
  else {
    return $days[$day % 7];
  }
}
drewish’s picture

Version: 5.x-1.0 » 5.x-1.x-dev

ah, then i think the correct thing to do would be for station_schedule_load() to put them in the correct order when it loads the node... rather than when we display them.

also try cvs -dP -A it should reset all the tags/branches to HEAD.

drewish’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev
StatusFileSize
new2.94 KB

give this patch for HEAD a test. i'm kind of stoked on how little code needs to be changed to get this working...assuming it's working for you too ;)

joachim’s picture

Yeah, that's pretty slick. It works perfectly for me.

By the way, I had a look at the way the Calendar and Date modules handle the week's start date. In calendar/calendar_api.inc, the function that's sort of equivalent to station_day_name() has a switch on the 'date_first_day' variable, and each case has the array of day names in a the different order... the code isn't not as nice to look at, and I have no idea which method is optimal. Just though I'd mention it though :)

drewish’s picture

Status: Needs review » Fixed

cool, them i'm going to commit it. the one thing i noticed that's a little weird is when adding a program sunday is still chosen as the default.

joachim’s picture

Yeah, noticed that too but figured it was nitpicking :)

techczech’s picture

subscribing

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

joachim’s picture

Status: Closed (fixed) » Active

The other thing that doesn't work is the list of times on a program node.
I'll look at it once I'm back on HEAD.

drewish’s picture

joachim, what do you mean that the list of times on the program node don't work? they're in the wrong order?

joachim’s picture

Suppose a program is on every day of the week. The list on the program node always starts with Sunday -- if we're allowing the site admin to change the order of days on the schedule, perhaps we should change the order of the list here too.

drewish’s picture

Status: Active » Needs review
StatusFileSize
new1.94 KB

give this a whirl. it uses some addition and modulo to wrap the entries.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Works great :)

drewish’s picture

Status: Reviewed & tested by the community » Fixed

great, committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.