fix date range

This commit is contained in:
Ben Harris 2020-06-23 15:46:46 -04:00
parent fd224caedc
commit 6addb64f5a
1 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,4 @@
<?php <?php
date_default_timezone_set("UTC");
include '../header.php'; include '../header.php';
include 'apikey.php'; include 'apikey.php';
@ -13,12 +12,12 @@ $context = stream_context_create([
] ]
]); ]);
$wk_begin = date("Y-m-d\TH:i:s\Z", strtotime("last sunday")); $from = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 1 day"));
$wk_end = date("Y-m-d\TH:i:s\Z", strtotime("next sunday")); $to = gmdate("Y-m-d\TH:i:s\Z", strtotime("now + 8 days"));
$schedule = json_decode( $schedule = json_decode(
file_get_contents( file_get_contents(
"https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$wk_begin&end=$wk_end&timeZone=UTC", "https://radio.tildeverse.org/api/station/1/streamers/schedule?start=$from&end=$to",
false, false,
$context $context
), ),
@ -26,11 +25,11 @@ $schedule = json_decode(
); );
usort($schedule, function ($a, $b) { usort($schedule, function ($a, $b) {
return $a["start"] < $b["start"] ? -1 : 1; return $a["start"] <=> $b["start"];
}); });
function formatdate($date) { function formatdate($date) {
return date("D M d H:i", strtotime($date)); return gmdate("D M d H:i", strtotime($date));
} }
?> ?>