Making WordPress.org


Ignore:
Timestamp:
03/25/2020 02:37:51 PM (5 years ago)
Author:
ryelle
Message:

Official WordPress Events: Sync the UTC offset to the database

start_timestamp is a fake UTC value, so we need to sync the real UTC offset to be able to get the real local time. This is a workaround because updating start_timestamp to be real UTC would cause more trouble (in the API, in core widget, etc).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php

    r9625 r9632  
    128128        foreach ( $events as $event ) {
    129129            $row_values = array(
    130                 'id'          => null,
    131                 'type'        => $event->type,
    132                 'source_id'   => $event->source_id,
    133                 'status'      => $event->status,
    134                 'title'       => $event->title,
    135                 'url'         => $event->url,
    136                 'description' => $event->description,
    137                 'attendees'   => $event->num_attendees,
    138                 'meetup'      => $event->meetup_name,
    139                 'meetup_url'  => $event->meetup_url,
    140                 'date_utc'    => date( 'Y-m-d H:i:s', $event->start_timestamp ),
    141                 'end_date'    => date( 'Y-m-d H:i:s', $event->end_timestamp ),
    142                 'location'    => $event->location,
    143                 'country'     => $event->country_code,
    144                 'latitude'    => $event->latitude,
    145                 'longitude'   => $event->longitude,
     130                'id'              => null,
     131                'type'            => $event->type,
     132                'source_id'       => $event->source_id,
     133                'status'          => $event->status,
     134                'title'           => $event->title,
     135                'url'             => $event->url,
     136                'description'     => $event->description,
     137                'attendees'       => $event->num_attendees,
     138                'meetup'          => $event->meetup_name,
     139                'meetup_url'      => $event->meetup_url,
     140                'date_utc'        => gmdate( 'Y-m-d H:i:s', $event->start_timestamp ),
     141                'end_date'        => gmdate( 'Y-m-d H:i:s', $event->end_timestamp ),
     142                'date_utc_offset' => $event->utc_offset,
     143                'location'        => $event->location,
     144                'country'         => $event->country_code,
     145                'latitude'        => $event->latitude,
     146                'longitude'       => $event->longitude,
    146147            );
    147148
    148             // Latitude and longitude are required by the database, so skip events that don't have one
     149            // Latitude and longitude are required by the database, so skip events that don't have one.
    149150            if ( empty( $row_values['latitude'] ) || empty( $row_values['longitude'] ) ) {
    150151                continue;
     
    475476                'num_attendees'   => $meetup['yes_rsvp_count'],
    476477                'start_timestamp' => $start_timestamp,
    477                 'end_timestamp'   => ( empty ( $meetup['duration'] ) ? $start_timestamp : $start_timestamp + ( $meetup['duration'] / 1000 ) ), // convert to seconds
     478                'end_timestamp'   => ( empty( $meetup['duration'] ) ? $start_timestamp : $start_timestamp + ( $meetup['duration'] / 1000 ) ), // convert to seconds.
     479                'utc_offset'      => $meetup['utc_offset'] / 1000, // convert to seconds.
    478480                'location'        => $location,
    479481                'country_code'    => $country_code,
Note: See TracChangeset for help on using the changeset viewer.