Skip to content

Commit 92edee8

Browse files
authored
Merge pull request #122 from Clpsplug/clpsplug/remove_not_so_forecast_measure
Removed the 'not-so-forecast' measure
2 parents a15fd88 + 3f1e34d commit 92edee8

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

Cmfcmf/OpenWeatherMap/WeatherForecast.php

-8
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,8 @@ public function __construct($xml, $units, $days)
7878
$this->sun = new Sun(new \DateTime($xml->sun['rise'], $utctz), new \DateTime($xml->sun['set'], $utctz));
7979
$this->lastUpdate = new \DateTime($xml->meta->lastupdate, $utctz);
8080

81-
$today = new \DateTime('now', $utctz);
82-
$today->setTime(0, 0, 0);
8381
$counter = 0;
8482
foreach ($xml->forecast->time as $time) {
85-
$date = new \DateTime(isset($time['day']) ? $time['day'] : $time['to'], $utctz);
86-
if ($date < $today) {
87-
// Sometimes OpenWeatherMap returns results which aren't real
88-
// forecasts. The best we can do is to ignore them.
89-
continue;
90-
}
9183
$forecast = new Forecast($time, $units);
9284
$forecast->city = $this->city;
9385
$forecast->sun = $this->sun;

tests/FakeData.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function forecastXML()
6565
</meta>
6666
<sun rise="2016-12-28T07:17:18" set="2016-12-28T14:59:55"></sun>
6767
<forecast>
68-
<time day="2016-12-20">
68+
<time day="' . date('Y-m-d', time() + 0) . '">
6969
<symbol number="500" name="light rain" var="10d"></symbol>
7070
<precipitation value="0.25" type="rain"></precipitation>
7171
<windDirection deg="315" code="NW" name="Northwest"></windDirection>
@@ -75,7 +75,7 @@ public static function forecastXML()
7575
<humidity value="97" unit="%"></humidity>
7676
<clouds value="overcast clouds" all="92" unit="%"></clouds>
7777
</time>
78-
<time day="' . date('Y-m-d') . '">
78+
<time day="' . date('Y-m-d', time() + 3600) . '">
7979
<symbol number="500" name="light rain" var="10d"></symbol>
8080
<precipitation value="0.24" type="rain"></precipitation>
8181
<windDirection deg="253" code="WSW" name="West-southwest"></windDirection>

tests/OpenWeatherMap/WeatherForecastTest.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,12 @@ public function testCurrent()
5555

5656
public function testNext()
5757
{
58-
$this->forecast->rewind();
5958
$this->forecast->next();
60-
$result = $this->forecast->valid();
61-
62-
$this->assertFalse($result);
59+
$this->assertTrue($this->forecast->valid());
6360
}
6461

6562
public function testValid()
6663
{
67-
$this->forecast->rewind();
68-
$this->forecast->next();
69-
$result = $this->forecast->valid();
70-
71-
$this->assertFalse($result);
64+
$this->assertTrue($this->forecast->valid());
7265
}
7366
}

0 commit comments

Comments
 (0)