function amr_derive_dates(&$e) { /* Derive basic date dependent data - called early on before repeating */ if (!isset($e['DTSTART'])) { return false; } if (is_array($e['DTSTART'])) { $e['DTSTART'] = $e['DTSTART'][0]; } if (isset($e['DTEND']) and is_array($e['DTEND'])) { $e['DTEND'] = $e['DTEND'][0]; } if (!is_object($e['DTSTART'])) { // show error more discretely - some people are working with really dodgy ics files echo '<p class="error"><a title="Error: Event with no date: ' . $e['SUMMARY'] . '">!</a>'; echo '</p>'; if (ICAL_EVENTS_DEBUG) { echo 'Dumping event record:'; var_dump($e); } return $e; } if (isset($e['DURATION']) and empty($e['DTEND'])) { /*** an array of the duration values, calc the end date or time */ $e['DTEND'] = new Datetime(); //if cloning dont need tz $e['DTEND'] = clone $e['DTSTART']; $e['DTEND'] = amr_add_duration_to_date($e['DTEND'], $e['DURATION']); } else { if (isset($e['DTEND']) and empty($e['DURATION'])) { /* we don't have a duration */ $e['DURATION'] = amr_calc_duration($e['DTSTART'], $e['DTEND']); /* calc the duration from the original values*/ } } if (isset($e['DTEND']) and is_object($e['DTEND'])) { if (!isset($e['allday']) and amr_is_all_day($e['DTSTART'], $e['DTEND'])) { // only chcek if not done $e['allday'] = 'allday'; } /* set EndDate as human version instead of technical DTEND */ $e['EndDate'] = new Datetime(); //if cloning dont need tz $e['EndDate'] = clone $e['DTEND']; if (isset($e['allday']) and $e['allday'] == 'allday') { date_modify($e['EndDate'], '-1 day'); } // for human view } return $e; }
function amr_event_is_multiday($event) { //determine if event is a multi day event if (empty($event['DURATION'])) { if (empty($event['EndDate'])) { return false; } else { $duration = amr_calc_duration($event['EventDate'], $event['EndDate']); } } else { $duration = $event['DURATION']; } if (isset($_GET['debugmulti'])) { echo '<br /> duration = '; var_dump($duration); } $days = 0; if (!empty($duration['days']) and $duration['days'] >= 1) { $days = $duration['days']; } if (!empty($duration['hours']) and $duration['hours'] >= 1 or !empty($duration['minutes']) and $duration['minutes'] >= 1 or !empty($duration['seconds']) and $duration['seconds'] >= 1) { // then we go over 1 day into the next $days = $days + 1; } if (!empty($duration['weeks']) and $duration['weeks'] >= 1) { $days = $days + 7 * $duration['weeks']; } if (isset($_GET['debugmulti'])) { echo '<br /> The number of days over which to show event ' . $event['SUMMARY'] . ' is = ' . $days; } return $days; }