adjust demos to work with PHP 5.2 or higher

This commit is contained in:
Adam Shaw
2014-01-25 00:59:37 -08:00
parent 18f41c3550
commit 0c6f0ff13c
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -6,11 +6,11 @@
//
// An optional "timezone" GET parameter will force all ISO8601 date stings to a given timezone.
//
// Requires PHP 5.3.0 or higher.
// Requires PHP 5.2.0 or higher.
//--------------------------------------------------------------------------------------------------
// Require our Event class and datetime utilities
require __DIR__ . '/utils.php';
require dirname(__FILE__) . '/utils.php';
// Short-circuit if the client did not give us a date range.
if (!isset($_GET['start']) || !isset($_GET['end'])) {
@@ -30,7 +30,7 @@ if (isset($_GET['timezone'])) {
}
// Read and parse our events JSON file into an array of event data arrays.
$json = file_get_contents(__DIR__ . '/../json/events.json');
$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
$input_arrays = json_decode($json, true);
// Accumulate an output array of event data arrays.
+1 -1
View File
@@ -3,7 +3,7 @@
//--------------------------------------------------------------------------------------------------
// This script outputs a JSON array of all timezones (like "America/Chicago") that PHP supports.
//
// Requires PHP 5.3.0 or higher.
// Requires PHP 5.2.0 or higher.
//--------------------------------------------------------------------------------------------------
echo json_encode(DateTimeZone::listIdentifiers());
+2 -2
View File
@@ -3,7 +3,7 @@
//--------------------------------------------------------------------------------------------------
// Utilities for our event-fetching scripts.
//
// Requires PHP 5.3.0 or higher.
// Requires PHP 5.2.0 or higher.
//--------------------------------------------------------------------------------------------------
// PHP will fatal error if we attempt to use the DateTime class without this being set.
@@ -111,7 +111,7 @@ class Event {
function parseDateTime($string, $timezone=null) {
$date = new DateTime(
$string,
$timezone ?: new DateTimeZone('UTC')
$timezone ? $timezone : new DateTimeZone('UTC')
// Used only when the string is ambiguous.
// Ignored if string has a timezone offset in it.
);