Skip to content

Commit 168d000

Browse files
authored
Merge pull request #13 from Waghabond/remove-timezone-alteration
Remove timezone alteration PR #2
2 parents 8bfc1d6 + ecf6b6b commit 168d000

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/WeatherFormat.php

+24-25
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@ public function __construct()
1818
* @param string $timestamp, int $tz
1919
* @return string
2020
*/
21-
public function dt(string $timestamp, int $tz)
21+
public function dt(string $timestamp)
2222
{
23-
return date($this->dateFormat, $timestamp + $tz);
23+
return date($this->dateFormat, $timestamp);
2424
}
2525

2626
public function formatCurrent($res)
2727
{
28-
$tz = $res->timezone;
2928
// modify date in given format
30-
$res->sys->sunrise = $this->dt($res->sys->sunrise, $tz);
31-
$res->sys->sunset = $this->dt($res->sys->sunset, $tz);
32-
$res->dt = $this->dt($res->dt, $tz);
29+
$res->sys->sunrise = date($this->dateFormat, $res->sys->sunrise);
30+
$res->sys->sunset = date($this->dateFormat, $res->sys->sunset);
31+
$res->dt = date($this->dateFormat, $res->dt);
3332

3433
return $res;
3534
}
@@ -41,33 +40,33 @@ public function formatOneCall($res)
4140

4241
// modify date of current data
4342

44-
$res->current->sunrise = $this->dt($res->current->sunrise, $tz);
45-
$res->current->sunset = $this->dt($res->current->sunset, $tz);
46-
$res->current->dt = $this->dt($res->current->dt, $tz);
43+
$res->current->sunrise = date($this->dateFormat, $res->current->sunrise);
44+
$res->current->sunset = date($this->dateFormat, $res->current->sunset);
45+
$res->current->dt = date($this->dateFormat, $res->current->dt);
4746

4847
// modify date of minutely data
4948

5049
if ($res->minutely) {
5150
foreach ($res->minutely as $key => $val) {
52-
$res->minutely[$key]->dt = $this->dt($val->dt, $tz);
51+
$res->minutely[$key]->dt = date($this->dateFormat, $val->dt);
5352
}
5453
}
5554

5655
// modify date of hourly data
5756

5857
if ($res->hourly) {
5958
foreach ($res->hourly as $key => $val) {
60-
$res->hourly[$key]->dt = $this->dt($val->dt, $tz);
59+
$res->hourly[$key]->dt = date($this->dateFormat, $val->dt);
6160
}
6261
}
6362

6463
// modify date of daily data
6564

6665
if ($res->daily) {
6766
foreach ($res->daily as $key => $val) {
68-
$res->daily[$key]->dt = $this->dt($val->dt, $tz);
69-
$res->daily[$key]->sunrise = $this->dt($val->sunrise, $tz);
70-
$res->daily[$key]->sunset = $this->dt($val->sunset, $tz);
67+
$res->daily[$key]->dt = date($this->dateFormat, $val->dt);
68+
$res->daily[$key]->sunrise = date($this->dateFormat, $val->sunrise);
69+
$res->daily[$key]->sunset = date($this->dateFormat, $val->sunset);
7170
}
7271
}
7372

@@ -79,13 +78,13 @@ public function format3Hourly($res)
7978
$tz = $res->city->timezone;
8079

8180
// modify date in given format
82-
$res->city->sunrise = $this->dt($res->city->sunrise, $tz);
83-
$res->city->sunset = $this->dt($res->city->sunset, $tz);
81+
$res->city->sunrise = date($this->dateFormat, $res->city->sunrise);
82+
$res->city->sunset = date($this->dateFormat, $res->city->sunset);
8483

8584
// modify date of list data
8685

8786
foreach ($res->list as $key => $val) {
88-
$res->list[$key]->dt = $this->dt($val->dt, $tz);
87+
$res->list[$key]->dt = date($this->dateFormat, $val->dt);
8988
}
9089

9190
return $res;
@@ -99,20 +98,20 @@ public function formatHistorical($res)
9998
// timestamps returned
10099
if (config('openweather.historical_api_version', '2.5') == '3.0') {
101100
// modify date of current data
102-
$res->data[0]->sunrise = $this->dt($res->data[0]->sunrise, $tz);
103-
$res->data[0]->sunset = $this->dt($res->data[0]->sunset, $tz);
104-
$res->data[0]->dt = $this->dt($res->data[0]->dt, $tz);
101+
$res->data[0]->sunrise = date($this->dateFormat, $res->data[0]->sunrise);
102+
$res->data[0]->sunset = date($this->dateFormat, $res->data[0]->sunset);
103+
$res->data[0]->dt = date($this->dateFormat, $res->data[0]->dt);
105104
return $res;
106105
}
107106

108107
// modify date of current data
109-
$res->current->sunrise = $this->dt($res->current->sunrise, $tz);
110-
$res->current->sunset = $this->dt($res->current->sunset, $tz);
111-
$res->current->dt = $this->dt($res->current->dt, $tz);
108+
$res->current->sunrise = date($this->dateFormat, $res->current->sunrise);
109+
$res->current->sunset = date($this->dateFormat, $res->current->sunset);
110+
$res->current->dt = date($this->dateFormat, $res->current->dt);
112111

113112
// modify date of hourly data
114113
foreach ($res->hourly as $key => $val) {
115-
$res->hourly[$key]->dt = $this->dt($val->dt, $tz);
114+
$res->hourly[$key]->dt = date($this->dateFormat, $val->dt);
116115
}
117116

118117
return $res;
@@ -121,7 +120,7 @@ public function formatHistorical($res)
121120
public function formatAirPollution($res)
122121
{
123122
foreach ($res->list as $key => $val) {
124-
$res->list[$key]->dt = $this->dt($val->dt, 0);
123+
$res->list[$key]->dt = date($this->dateFormat, $val->dt);
125124
}
126125

127126
return $res;

0 commit comments

Comments
 (0)