Changeset 10252
- Timestamp:
- 09/11/2020 06:08:05 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php
r10251 r10252 343 343 } 344 344 345 $event['start_timestamp'] = $this->get_wordcamp_start_time( $value, absint( $wordcamp->session_start_time ) ); 345 $event['start_timestamp'] = $this->get_wordcamp_start_time( 346 $value, 347 absint( $wordcamp->session_start_time ), 348 $event['utc_offset'] 349 ); 350 346 351 break; 347 352 … … 430 435 * Determine the best start time for a WordCamp. 431 436 * 432 * The timestamp from the WordCamp post type only tell us the date that the camp is on, not whenit starts.433 * The earliest session can be used to get the time that the camp starts, but it's likely to be inaccurate437 * The WP timestamp from the WordCamp post type only tell us the date that the camp is on, not what time it starts. 438 * The earliest session Unix timestamp can be used to get the time that the camp starts, but it's likely to be inaccurate 434 439 * if it doesn't match the date from the WordCamp post. One common cause of that is when an event is 435 440 * postponed, but the organizers haven't gone through and updated all of the sessions yet. 436 441 * 437 * @param string $start_date 438 * @param string $first_session_start_time 439 * 440 * @return string 441 */ 442 protected function get_wordcamp_start_time( $start_date, $first_session_start_time ) { 443 $session_time_is_same_day = date( 'Ymd', $start_date ) === date( 'Ymd', $first_session_start_time ); 444 445 return $session_time_is_same_day ? $first_session_start_time : $start_date; 442 * @param string $start_date _WP_ timestamp. 443 * @param string $first_session_start_time _Unix_ timestamp. 444 * @param int $utc_offset The event's UTC offset in seconds. 445 * 446 * @return string Returns a _WP_ timestamp. 447 */ 448 protected function get_wordcamp_start_time( $start_date, $first_session_start_time, $utc_offset ) { 449 if ( ! $utc_offset ) { 450 return $start_date; 451 } 452 453 // Convert the Unix timestamp to a WP timestamp, so we can compare apples to apples. 454 $first_session_wp = (int) $first_session_start_time + $utc_offset; 455 $session_time_is_same_day = date( 'Ymd', $start_date ) === date( 'Ymd', $first_session_wp ); 456 457 return $session_time_is_same_day ? $first_session_wp : $start_date; 446 458 } 447 459
Note: See TracChangeset
for help on using the changeset viewer.