Hey there, I've made a small function for a radio program guide to figure out what's on "now, next and later" in the calendar based on the time - not just the day as the upcoming events function does.
My problem lies with events that have more than one RecurringDaysOfWeek (e.g. Monday to Friday - 6am to 9am).
They show up fine in UpcomingEvents, but when I try to filter them by times, these "multiple days per week" events do not show. Events that only have one day per week work fine.
Can anyone shed some light as to why it's only problematic with these "multiple days per week" events?
Here is my function to filter by time (it's in 30 min blocks because that is the absolute minimum length of a show)
class NowOnWidget_Controller extends Widget_Controller {
public function UpcomingEvents() {
//Get Current Date/Time
$now = array(
'date' => date("Y-m-d"),
'time' => date("H:i:s"),
);
//Split and round up Current Time
$ts = split(":",$now['time']);
$ts[2] = "00";
if($ts[1] < 31){
$ts[1] = 30;
}else{
$ts[0]++;
$ts[1] = "00";
}
//Create a list of half hour blocks in the next 24hrs
$i = 0;
$times = array();
while($i < 48){
if($ts[0] == 24){
$ts[0] = "00";
$i = 47;
}
$times[] = $ts[0].":".$ts[1].":".$ts[2];
$ts[1] = $ts[1]+30;
if($ts[1] == 60){
$ts[0]++;
$ts[1] = "00";
}
$i++;
}
//print_r($times);
//Return filtered Events
$all = Calendar::get()->first()->UpcomingEvents(9);
$uc = $all->filter(array('EndTime' => $times))->limit(3);
return $uc;
}
}
I'm using SS 3.0.5