Index: /sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
===================================================================
--- /sites/trunk/api.wordpress.org/public_html/events/1.0/index.php (revision 10269)
+++ /sites/trunk/api.wordpress.org/public_html/events/1.0/index.php (revision 10270)
@@ -35,5 +35,6 @@
define( 'THROTTLE_IP2LOCATION', 0 );
- defined( 'DAY_IN_SECONDS' ) or define( 'DAY_IN_SECONDS', 60 * 60 * 24 );
+ defined( 'HOUR_IN_SECONDS' ) or define( 'HOUR_IN_SECONDS', 60 * 60 );
+ defined( 'DAY_IN_SECONDS' ) or define( 'DAY_IN_SECONDS', HOUR_IN_SECONDS * 24 );
defined( 'WEEK_IN_SECONDS' ) or define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
@@ -869,6 +870,15 @@
'meetup' => $event->meetup,
'meetup_url' => $event->meetup_url,
- 'date' => $event->date_utc, // TODO: DB stores a local date, not UTC.
+
+ /*
+ * The `date_utc` column in the database is misnomed, and contains times in the event's local
+ * timezone. So the `date` field in the response is the local time, and the `date_utc` field in
+ * the response here is _actually_ UTC.
+ */
+ 'date' => $event->date_utc,
'end_date' => $event->end_date,
+ 'start_unix_timestamp' => strtotime( $event->date_utc ) - $event->date_utc_offset,
+ 'end_unix_timestamp' => strtotime( $event->end_date ) - $event->date_utc_offset,
+
'location' => array(
@@ -1032,4 +1042,6 @@
'date' => '2020-02-21 00:00:00',
'end_date' => '2020-02-23 00:00:00',
+ 'start_unix_timestamp' => strtotime( '2020-02-21 00:00:00' ) - 7 * HOUR_IN_SECONDS,
+ 'end_unix_timestamp' => strtotime( '2020-02-23 00:00:00' ) - 7 * HOUR_IN_SECONDS,
'location' => array(
@@ -1057,4 +1069,6 @@
'date' => '2020-06-04 00:00:00',
'end_date' => '2020-06-06 00:00:00',
+ 'start_unix_timestamp' => strtotime( '2020-06-04 00:00:00' ) - 1 * HOUR_IN_SECONDS,
+ 'end_unix_timestamp' => strtotime( '2020-06-06 00:00:00' ) - 1 * HOUR_IN_SECONDS,
'location' => array(
@@ -1083,4 +1097,6 @@
'date' => '2020-10-27 00:00:00',
'end_date' => '2020-10-29 00:00:00',
+ 'start_unix_timestamp' => strtotime( '2020-10-27 00:00:00' ) - 5 * HOUR_IN_SECONDS,
+ 'end_unix_timestamp' => strtotime( '2020-10-29 00:00:00' ) - 5 * HOUR_IN_SECONDS,
'location' => array(
@@ -1271,4 +1287,5 @@
'meetup_url' => '',
'date' => '2018-05-27 12:00:00',
+
'location' => array(
'location' => 'Everywhere',
@@ -1341,5 +1358,5 @@
$raw_camp = $wpdb->get_row( "
SELECT
- `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude`
+ `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude`
FROM `wporg_events`
WHERE
@@ -1359,6 +1376,10 @@
'meetup' => $raw_camp->meetup,
'meetup_url' => $raw_camp->meetup_url,
+
+ // See notes about UTC in `get_events()`.
'date' => $raw_camp->date_utc,
'end_date' => $raw_camp->end_date,
+ 'start_unix_timestamp' => strtotime( $raw_camp->date_utc ) - $raw_camp->date_utc_offset,
+ 'end_unix_timestamp' => strtotime( $raw_camp->end_date ) - $raw_camp->date_utc_offset,
'location' => array(
@@ -1416,5 +1437,5 @@
if ( ! $found ) {
$raw_discussion_group = $wpdb->get_row( "
- SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude`
+ SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude`
FROM `wporg_events`
WHERE
@@ -1435,6 +1456,10 @@
'meetup' => $raw_discussion_group->meetup,
'meetup_url' => $raw_discussion_group->meetup_url,
+
+ // See notes about UTC in `get_events()`.
'date' => $raw_discussion_group->date_utc,
'end_date' => $raw_discussion_group->end_date,
+ 'start_unix_timestamp' => strtotime( $raw_discussion_group->date_utc ) - $raw_discussion_group->date_utc_offset,
+ 'end_unix_timestamp' => strtotime( $raw_discussion_group->end_date ) - $raw_discussion_group->date_utc_offset,
'location' => array(