You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To allow an arbitrary range to be selected using the eventsFromRange method I
altered the code to the following, bool start and end are still accepted and
should give same result as before (i.e. shouldn't break existing
implementations)
/**
* Returns false when the current calendar has no events in range, else the
* events.
*
* Note that this function makes use of a UNIX timestamp. This might be a
* problem on January the 29th, 2038.
* See http://en.wikipedia.org/wiki/Unix_time#Representing_the_number
*
* @param {boolean} or {time} $rangeStart Either true or false or unix timestamp
* @param {boolean} or {time} $rangeEnd Either true or false or unix timestamp
*
* @return {mixed}
*/
public function eventsFromRange($rangeStart = false, $rangeEnd = false)
{
$events = $this->sortEventsWithOrder($this->events(), SORT_ASC);
if (!$events) {
return false;
}
$extendedEvents = array();
if ($rangeStart === true) {
$rangeStart = time();
} else if ($rangeStart === false) {
$rangeStart = 0;
}
if ($rangeEnd === true or ($rangeEnd <= $rangeStart && $rangeStart <= time())) {
$rangeEnd = time();
} else if ($rangeEnd === false or $rangeEnd <= $rangeStart) {
$rangeEnd = strtotime('2038-01-18');
}
// loop through all events by adding two new elements
foreach ($events as $anEvent) {
$dtStart = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
$dtEnd = $this->iCalDateToUnixTimestamp($anEvent['DTEND']);
if ($dtEnd >= $rangeStart && $dtStart <= $rangeEnd) $extendedEvents[] = $anEvent;
}
return $extendedEvents;
}
Original issue reported on code.google.com by maw.des...@gmail.com on 29 Jan 2012 at 9:09
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
maw.des...@gmail.com
on 29 Jan 2012 at 9:09The text was updated successfully, but these errors were encountered: