Exemple #1
0
 /**
  * Given a date and an event, returns true or false if the event is happening on that date
  * This function properly adjusts for the EOD cutoff and multi-day events
  *
  * @param null $date
  * @param null $event
  *
  * @return mixed|void
  */
 function tribe_event_is_on_date($date = null, $event = null)
 {
     if (null === $date) {
         $date = current_time('mysql');
     }
     if (null === $event) {
         global $post;
         $event = $post;
         if (empty($event)) {
             _doing_it_wrong(__FUNCTION__, esc_html__('The function needs to be passed an $event or used in the loop.', 'the-events-calendar'));
             return false;
         }
     }
     $start_of_day = tribe_beginning_of_day($date, 'U');
     $end_of_day = tribe_end_of_day($date, 'U');
     $event_start = tribe_get_start_date($event, null, 'U');
     $event_end = tribe_get_end_date($event, null, 'U');
     // kludge
     if (!empty($event->_end_date_fixed)) {
         // @todo remove this once we can have all day events without a start / end time
         $event_end = date_create(date(Tribe__Date_Utils::DBDATETIMEFORMAT, $event_end));
         $event_end->modify('+1 day');
         $event_end = $event_end->format('U');
     }
     /* note:
      * events that start exactly on the EOD cutoff will count on the following day
      * events that end exactly on the EOD cutoff will count on the previous day
      */
     $event_is_on_date = Tribe__Date_Utils::range_coincides($start_of_day, $end_of_day, $event_start, $event_end);
     return apply_filters('tribe_event_is_on_date', $event_is_on_date, $date, $event);
 }