/**
  * Updates the next batch of non-timezone ready events.
  *
  * @param int $batch_size (defaults to -1 meaning "update all")
  */
 public function process($batch_size = -1)
 {
     $site_timezone = Tribe__Timezones::wp_timezone_string();
     foreach ($this->get_ids($batch_size) as $event_id) {
         $local_start_time = tribe_get_start_date($event_id, true, Tribe__Date_Utils::DBDATETIMEFORMAT);
         $utc_start_time = Tribe__Timezones::to_utc($local_start_time, $site_timezone);
         $local_end_time = tribe_get_end_date($event_id, true, Tribe__Date_Utils::DBDATETIMEFORMAT);
         $utc_end_time = Tribe__Timezones::to_utc($local_end_time, $site_timezone);
         // The abbreviation needs to be calculated per event as it can vary according to the actual date
         $site_timezone_abbr = Tribe__Timezones::wp_timezone_abbr($local_start_time);
         update_post_meta($event_id, '_EventTimezone', $site_timezone);
         update_post_meta($event_id, '_EventTimezoneAbbr', $site_timezone_abbr);
         update_post_meta($event_id, '_EventStartDateUTC', $utc_start_time);
         update_post_meta($event_id, '_EventEndDateUTC', $utc_end_time);
     }
 }
 /**
  * Parses a timezone string candidate and returns a TEC supported timezone string.
  *
  * @param string $timezone_candidate
  *
  * @return bool|string Either the timezone string or `false` if the timezone candidate is invalid.
  */
 private function get_timezone($timezone_candidate)
 {
     if (Tribe__Timezones::is_utc_offset($timezone_candidate)) {
         return $timezone_candidate;
     }
     return Tribe__Timezones::get_timezone($timezone_candidate, false) ? $timezone_candidate : false;
 }
 public static function init()
 {
     self::display_timezones();
     parent::init();
 }
Beispiel #4
0
 /**
  * Get the first day of the week from a provided date
  *
  * @param null|mixed $date  given date or week # (week # assumes current year)
  *
  * @return string
  * @todo move logic to Tribe__Date_Utils
  */
 function tribe_get_first_week_day($date = null)
 {
     global $wp_query;
     $offset = 7 - get_option('start_of_week', 0);
     if (tribe_is_ajax_view_request()) {
         $date = is_null($date) ? $_REQUEST['eventDate'] : $date;
     } else {
         $date = is_null($date) ? $wp_query->get('start_date') : $date;
     }
     $timezone = Tribe__Timezones::wp_timezone_string();
     $timezone = Tribe__Timezones::generate_timezone_string_from_utc_offset($timezone);
     try {
         $date = new DateTime($date, new DateTimeZone($timezone));
     } catch (exception $e) {
         $date = new DateTime(current_time('Y-m-d'), new DateTimeZone($timezone));
     }
     // Clone to avoid altering the original date
     $r = clone $date;
     $r->modify(-(($date->format('w') + $offset) % 7) . 'days');
     return apply_filters('tribe_get_first_week_day', $r->format('Y-m-d'));
 }