diff --git 1.0/index.php 1.0/index.php
index ee81304..132ae97 100644
|
|
function main() { |
34 | 34 | define( 'THROTTLE_GEONAMES', 0 ); |
35 | 35 | define( 'THROTTLE_IP2LOCATION', 0 ); |
36 | 36 | |
37 | | defined( 'DAY_IN_SECONDS' ) or define( 'DAY_IN_SECONDS', 60 * 60 * 24 ); |
| 37 | defined( 'HOUR_IN_SECONDS' ) or define( 'HOUR_IN_SECONDS', 60 * 60 ); |
| 38 | defined( 'DAY_IN_SECONDS' ) or define( 'DAY_IN_SECONDS', HOUR_IN_SECONDS * 24 ); |
38 | 39 | defined( 'WEEK_IN_SECONDS' ) or define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS ); |
39 | 40 | |
40 | 41 | // The test suite just needs the functions defined and doesn't want any headers or output |
… |
… |
function get_events( $args = array() ) { |
868 | 869 | 'url' => $event->url, |
869 | 870 | 'meetup' => $event->meetup, |
870 | 871 | 'meetup_url' => $event->meetup_url, |
871 | | 'date' => $event->date_utc, // TODO: DB stores a local date, not UTC. |
| 872 | |
| 873 | /* |
| 874 | * The `date_utc` column in the database is misnomed, and contains times in the event's local |
| 875 | * timezone. So the `date` field in the response is the local time, and the `date_utc` field in |
| 876 | * the response here is _actually_ UTC. |
| 877 | */ |
| 878 | 'date' => $event->date_utc, |
872 | 879 | 'end_date' => $event->end_date, |
| 880 | 'start_unix_timestamp' => strtotime( $event->date_utc ) - $event->date_utc_offset, |
| 881 | 'end_unix_timestamp' => strtotime( $event->end_date ) - $event->date_utc_offset, |
| 882 | |
873 | 883 | |
874 | 884 | 'location' => array( |
875 | 885 | // Capitalize it for use in presentation contexts, like the Events Widget. |
… |
… |
function get_regional_wordcamp_data() { |
1031 | 1041 | 'meetup_url' => '', |
1032 | 1042 | 'date' => '2020-02-21 00:00:00', |
1033 | 1043 | 'end_date' => '2020-02-23 00:00:00', |
| 1044 | 'start_unix_timestamp' => strtotime( '2020-02-21 00:00:00' ) - 7 * HOUR_IN_SECONDS, |
| 1045 | 'end_unix_timestamp' => strtotime( '2020-02-23 00:00:00' ) - 7 * HOUR_IN_SECONDS, |
1034 | 1046 | |
1035 | 1047 | 'location' => array( |
1036 | 1048 | 'location' => 'Bangkok, Thailand', |
… |
… |
function get_regional_wordcamp_data() { |
1056 | 1068 | 'meetup_url' => '', |
1057 | 1069 | 'date' => '2020-06-04 00:00:00', |
1058 | 1070 | 'end_date' => '2020-06-06 00:00:00', |
| 1071 | 'start_unix_timestamp' => strtotime( '2020-06-04 00:00:00' ) - 1 * HOUR_IN_SECONDS, |
| 1072 | 'end_unix_timestamp' => strtotime( '2020-06-06 00:00:00' ) - 1 * HOUR_IN_SECONDS, |
1059 | 1073 | |
1060 | 1074 | 'location' => array( |
1061 | 1075 | 'location' => 'Online', |
… |
… |
function get_regional_wordcamp_data() { |
1082 | 1096 | 'meetup_url' => '', |
1083 | 1097 | 'date' => '2020-10-27 00:00:00', |
1084 | 1098 | 'end_date' => '2020-10-29 00:00:00', |
| 1099 | 'start_unix_timestamp' => strtotime( '2020-10-27 00:00:00' ) - 5 * HOUR_IN_SECONDS, |
| 1100 | 'end_unix_timestamp' => strtotime( '2020-10-29 00:00:00' ) - 5 * HOUR_IN_SECONDS, |
1085 | 1101 | |
1086 | 1102 | 'location' => array( |
1087 | 1103 | 'location' => 'Online', |
… |
… |
function maybe_add_wp15_promo( $local_events, $user_agent, $time ) { |
1270 | 1286 | 'meetup' => '', |
1271 | 1287 | 'meetup_url' => '', |
1272 | 1288 | 'date' => '2018-05-27 12:00:00', |
| 1289 | 'end_date' => '2018-05-27 12:00:00', |
| 1290 | 'start_unix_timestamp' => strtotime( '2018-05-27 12:00:00' ), |
| 1291 | 'end_unix_timestamp' => strtotime( '2018-05-27 12:00:00' ), |
| 1292 | |
1273 | 1293 | 'location' => array( |
1274 | 1294 | 'location' => 'Everywhere', |
1275 | 1295 | ), |
… |
… |
function pin_next_online_wordcamp( $events, $user_agent, $current_time ) { |
1340 | 1360 | if ( false === $next_online_camp ) { |
1341 | 1361 | $raw_camp = $wpdb->get_row( " |
1342 | 1362 | SELECT |
1343 | | `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude` |
| 1363 | `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude` |
1344 | 1364 | FROM `wporg_events` |
1345 | 1365 | WHERE |
1346 | 1366 | type = 'wordcamp' AND |
… |
… |
function pin_next_online_wordcamp( $events, $user_agent, $current_time ) { |
1358 | 1378 | 'url' => $raw_camp->url, |
1359 | 1379 | 'meetup' => $raw_camp->meetup, |
1360 | 1380 | 'meetup_url' => $raw_camp->meetup_url, |
| 1381 | |
| 1382 | // See notes about UTC in `get_events()`. |
1361 | 1383 | 'date' => $raw_camp->date_utc, |
1362 | 1384 | 'end_date' => $raw_camp->end_date, |
| 1385 | 'start_unix_timestamp' => strtotime( $raw_camp->date_utc ) - $raw_camp->date_utc_offset, |
| 1386 | 'end_unix_timestamp' => strtotime( $raw_camp->end_date ) - $raw_camp->date_utc_offset, |
| 1387 | |
| 1388 | // cod standards commit after this commit |
1363 | 1389 | |
1364 | 1390 | 'location' => array( |
1365 | 1391 | 'location' => 'Online', |
… |
… |
function pin_next_workshop_discussion_group( $events, $user_agent ) { |
1415 | 1441 | |
1416 | 1442 | if ( ! $found ) { |
1417 | 1443 | $raw_discussion_group = $wpdb->get_row( " |
1418 | | SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `end_date`, `country`, `latitude`, `longitude` |
| 1444 | SELECT `title`, `url`, `meetup`, `meetup_url`, `date_utc`, `date_utc_offset`, `end_date`, `country`, `latitude`, `longitude` |
1419 | 1445 | FROM `wporg_events` |
1420 | 1446 | WHERE |
1421 | 1447 | type = 'meetup' AND |
… |
… |
function pin_next_workshop_discussion_group( $events, $user_agent ) { |
1434 | 1460 | 'url' => $raw_discussion_group->url, |
1435 | 1461 | 'meetup' => $raw_discussion_group->meetup, |
1436 | 1462 | 'meetup_url' => $raw_discussion_group->meetup_url, |
| 1463 | |
| 1464 | // See notes about UTC in `get_events()`. |
1437 | 1465 | 'date' => $raw_discussion_group->date_utc, |
1438 | 1466 | 'end_date' => $raw_discussion_group->end_date, |
| 1467 | 'start_unix_timestamp' => strtotime( $raw_discussion_group->date_utc ) - $raw_discussion_group->date_utc_offset, |
| 1468 | 'end_unix_timestamp' => strtotime( $raw_discussion_group->end_date ) - $raw_discussion_group->date_utc_offset, |
1439 | 1469 | |
1440 | 1470 | 'location' => array( |
1441 | 1471 | 'location' => 'Online', |