|
18 | 18 | namespace Cmfcmf\OpenWeatherMap; |
19 | 19 |
|
20 | 20 | use Cmfcmf\OpenWeatherMap; |
| 21 | +use Cmfcmf\OpenWeatherMap\Util\City; |
21 | 22 |
|
22 | 23 | /** |
23 | 24 | * Class WeatherHistory. |
@@ -62,17 +63,40 @@ public function __construct($weatherHistory, $query) |
62 | 63 | $population = null; |
63 | 64 | } |
64 | 65 |
|
65 | | - $this->city = new OpenWeatherMap\Util\City($weatherHistory['city_id'], (is_string($query)) ? $query : null, (isset($query['lon'])) ? $query['lon'] : null, (isset($query['lat'])) ? $query['lat'] : null, $country, $population); |
| 66 | + $this->city = new City( |
| 67 | + $weatherHistory['city_id'], |
| 68 | + (is_string($query)) ? $query : null, |
| 69 | + (isset($query['lon'])) ? $query['lon'] : null, |
| 70 | + (isset($query['lat'])) ? $query['lat'] : null, |
| 71 | + $country, |
| 72 | + $population |
| 73 | + ); |
66 | 74 | $this->calctime = $weatherHistory['calctime']; |
67 | 75 |
|
| 76 | + $utctz = new \DateTimeZone('UTC'); |
68 | 77 | foreach ($weatherHistory['list'] as $history) { |
69 | 78 | if (isset($history['rain'])) { |
70 | 79 | $units = array_keys($history['rain']); |
71 | 80 | } else { |
72 | 81 | $units = array(0 => null); |
73 | 82 | } |
74 | 83 |
|
75 | | - $this->histories[] = new History($this->city, $history['weather'][0], array('now' => $history['main']['temp'], 'min' => $history['main']['temp_min'], 'max' => $history['main']['temp_max']), $history['main']['pressure'], $history['main']['humidity'], $history['clouds']['all'], isset($history['rain']) ? array('val' => $history['rain'][($units[0])], 'unit' => $units[0]) : null, $history['wind'], \DateTime::createFromFormat('U', $history['dt'])); |
| 84 | + $this->histories[] = new History( |
| 85 | + $this->city, |
| 86 | + $history['weather'][0], |
| 87 | + array( |
| 88 | + 'now' => $history['main']['temp'], |
| 89 | + 'min' => $history['main']['temp_min'], |
| 90 | + 'max' => $history['main']['temp_max'] |
| 91 | + ), |
| 92 | + $history['main']['pressure'], |
| 93 | + $history['main']['humidity'], |
| 94 | + $history['clouds']['all'], |
| 95 | + isset($history['rain']) ? array( |
| 96 | + 'val' => $history['rain'][($units[0])], |
| 97 | + 'unit' => $units[0]) : null, |
| 98 | + $history['wind'], |
| 99 | + \DateTime::createFromFormat('U', $history['dt'], $utctz)); |
76 | 100 | } |
77 | 101 | } |
78 | 102 |
|
|
0 commit comments