diff options
| author | Luke Bratch <luke@bratch.co.uk> | 2022-01-26 09:05:03 +0000 | 
|---|---|---|
| committer | Luke Bratch <luke@bratch.co.uk> | 2022-01-26 09:05:03 +0000 | 
| commit | ea628ef91b4eb24ee6db41e1bfd75ba0b058982c (patch) | |
| tree | ddfe6d115cbc815a73653d613647eb07808134cc | |
| parent | cdef5b03f0c0239b329dc0b0fb0760e9211eccf8 (diff) | |
Only show title summary for current time onwards, split up with timestamps
| -rw-r--r-- | index.php | 15 | 
1 files changed, 13 insertions, 2 deletions
| @@ -9,7 +9,8 @@  <?php  libxml_use_internal_errors(true); -date_default_timezone_set("UTC"); +date_default_timezone_set("Europe/Jersey"); +$timenow = time();  $json = file_get_contents("https://prodgojweatherstorage.blob.core.windows.net/data/jerseyForecast.json");  $arr_json = json_decode($json, true); @@ -25,6 +26,7 @@ $uv[0] = $arr_json['forecastDay']['0']['uvIndex'];  $morning[0] = $arr_json['forecastDay']['0']['morningDescripiton']; // Try to...  $afternoon[0] = $arr_json['forecastDay']['0']['afternoonDescripiton']; // ...find a...  $night[0] = $arr_json['forecastDay']['0']['nightDescripiton']; // ...day summary +$sunset[0] = $arr_json['forecastDay']['0']['sunSet'];  $frost[0] = $arr_json['forecastDay']['0']['frost'];  $winddesc[0] = $arr_json['forecastDay']['0']['windDescription']; @@ -40,8 +42,17 @@ $night[1] = $arr_json['forecastDay']['1']['nightDescripiton'];  $frost[1] = $arr_json['forecastDay']['1']['frost'];  $winddesc[1] = $arr_json['forecastDay']['1']['windDescription']; +// Title summary -echo "<title>Max $maxtemp[0], Min $mintemp[0], Cur $curtemp, UV $uv[0], Wind $wind[0], $morning[0] $afternoon[0] $night[0] $frost[0]</title>\n\n"; +if ($timenow >= strtotime($sunset[0])) { +  $summary[0] = "$sunset[0]: $night[0]"; +} else if ($timenow >= strtotime("12:00:00")) { +  $summary[0] = "12:00: $afternoon[0] $sunset[0]: $night[0]"; +} else { +  $summary[0] = "00:00: $morning[0] 12:00: $afternoon[0] $sunset[0]: $night[0]"; +} + +echo "<title>Max $maxtemp[0], Min $mintemp[0], Cur $curtemp, UV $uv[0], Wind $wind[0], $summary[0] $frost[0]</title>\n\n";  echo "</head>\n\n";  echo "<body>\n\n"; | 
