Hi There,
I am trying to do a (basic?) thing with UpcomingEvents()...
I want it to display the current event, followed by 2 next events in the first calendar, although I have noticed that UpcomingEvents() only returns results based on dates rather than times...
Is there another way to do this? I have tried using ->filter("EndTime:GreaterThan", date("H:m:s")) to no avail, as it seems :GreaterThan doesn't work on time fields???.
Maybe there is an easier field to be filtering my dates from? (the "dtend" span in the $DateRange template variable would be good if it wasn't wrapped with HTML)
The end goal is to have a widget displaying "Now", "Next" and "Later" from the calendar.
I am currently resorting to this function that assumes all items are set to start and finish on the half hour.
I've made it so it can't collect anything past midnight, as unfortunately the Item List does not get ordered by the order of my $times array.
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++;
}
//Return filtered Events
$all = Calendar::get()->first()->UpcomingEvents(20);
return $all->filter(array('EndTime' => $times))->limit(3);
}
Hope you can help, and thanks :)