/** * End Date * * Returns the event end date * * @category Events * @param int $event (optional) * @param bool $displayTime If true shows date and time, if false only shows date * @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php) * * @return string|null Date */ function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '') { if (is_null($event)) { global $post; $event = $post; } if (is_numeric($event)) { $event = get_post($event); } if (tribe_event_is_all_day($event)) { $displayTime = false; } if (empty($event->EventEndDate) && is_object($event)) { $event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true); } if (isset($event->EventEndDate)) { if (tribe_event_is_all_day($event) && empty($event->_end_date_fixed) && Tribe__Events__Date_Utils::timeOnly($event->EventEndDate) != '23:59:59' && Tribe__Events__Date_Utils::timeOnly(tribe_event_end_of_day()) != '23:59') { // set the event end date to be one day earlier, if it's an all day event and the cutoff is past midnight // @todo remove this once we can have all day events without a start / end time $event->EventEndDate = date_create($event->EventEndDate); $event->EventEndDate->modify('-1 day'); $event->EventEndDate = $event->EventEndDate->format(Tribe__Events__Date_Utils::DBDATEFORMAT); $event->_end_date_fixed = true; } $date = strtotime($event->EventEndDate); } else { return; } return tribe_event_format_date($date, $displayTime, $dateFormat); }
/** * If it's an all day event and the EOD cutoff is later than midnight * set the end date to be the previous day so it displays correctly in the datepicker * so the datepickers will match. we'll set the correct end time upon saving * * @todo remove this once we're allowed to have all day events without a start/end time */ protected function eod_correction() { $all_day = $this->vars['_EventAllDay']; $end_date = $this->vars['_EventEndDate']; $ends_at_midnight = '23:59:59' === Tribe__Events__Date_Utils::timeOnly($end_date); $midnight_cutoff = '23:59:59' === Tribe__Events__Date_Utils::timeOnly(tribe_event_end_of_day()); if (!$all_day || $ends_at_midnight || $midnight_cutoff) { return; } $end_date = date_create($this->vars['_EventEndDate']); $end_date->modify('-1 day'); $this->vars['_EventEndDate'] = $end_date->format(Tribe__Events__Date_Utils::DBDATETIMEFORMAT); }