diff --git a/src/WeatherService.php b/src/WeatherService.php index a4a2390..2062cbc 100755 --- a/src/WeatherService.php +++ b/src/WeatherService.php @@ -6,6 +6,7 @@ use GuzzleHttp\ClientInterface; use Drupal\Component\Utility\Html; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\ConnectException; +use Drupal\Component\Datetime\DateTimePlus; /** * Service to manage conection to openweathermap. @@ -283,7 +284,8 @@ class WeatherService { foreach ($output['list'] as $key => $data) { $html[$key]['forecast_time'] = date("g:i a", strtotime($output['list'][$key]['dt_txt'])); - $html[$key]['forecast_date'] = date("F d", $output['list'][$key]['dt']); + $time = DateTimePlus::createFromTimestamp($output['list'][$key]['dt'], 'UTC'); + $html[$key]['forecast_date'] = $time->format("F d"); foreach ($config['outputitems'] as $value) { if (!empty($config['outputitems'][$value])) { switch ($config['outputitems'][$value]) { @@ -346,7 +348,7 @@ class WeatherService { break; case 'day': - $html[$key][$value] = gmstrftime("%A", $output['list'][$key]['dt']); + $html[$key][$value] = $time->format('l'); break; case 'country': @@ -382,7 +384,8 @@ class WeatherService { } foreach ($output['list'] as $key => $data) { - $html[$key]['forecast_date'] = gmstrftime("%B %d", $output['list'][$key]['dt']); + $time = DateTimePlus::createFromTimestamp($output['list'][$key]['dt'], 'UTC'); + $html[$key]['forecast_date'] = $time->format("F d"); foreach ($config['outputitems'] as $value) { if (!empty($config['outputitems'][$value])) { switch ($config['outputitems'][$value]) { @@ -445,7 +448,7 @@ class WeatherService { break; case 'day': - $html[$key][$value] = gmstrftime("%A", $output['list'][$key]['dt']); + $html[$key][$value] = $time->format('l'); break; case 'country':