Skip to content

Commit

Permalink
Merge pull request #122 from Clpsplug/clpsplug/remove_not_so_forecast…
Browse files Browse the repository at this point in the history
…_measure

Removed the 'not-so-forecast' measure
  • Loading branch information
cmfcmf authored May 9, 2018
2 parents a15fd88 + 3f1e34d commit 92edee8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
8 changes: 0 additions & 8 deletions Cmfcmf/OpenWeatherMap/WeatherForecast.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,8 @@ public function __construct($xml, $units, $days)
$this->sun = new Sun(new \DateTime($xml->sun['rise'], $utctz), new \DateTime($xml->sun['set'], $utctz));
$this->lastUpdate = new \DateTime($xml->meta->lastupdate, $utctz);

$today = new \DateTime('now', $utctz);
$today->setTime(0, 0, 0);
$counter = 0;
foreach ($xml->forecast->time as $time) {
$date = new \DateTime(isset($time['day']) ? $time['day'] : $time['to'], $utctz);
if ($date < $today) {
// Sometimes OpenWeatherMap returns results which aren't real
// forecasts. The best we can do is to ignore them.
continue;
}
$forecast = new Forecast($time, $units);
$forecast->city = $this->city;
$forecast->sun = $this->sun;
Expand Down
4 changes: 2 additions & 2 deletions tests/FakeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function forecastXML()
</meta>
<sun rise="2016-12-28T07:17:18" set="2016-12-28T14:59:55"></sun>
<forecast>
<time day="2016-12-20">
<time day="' . date('Y-m-d', time() + 0) . '">
<symbol number="500" name="light rain" var="10d"></symbol>
<precipitation value="0.25" type="rain"></precipitation>
<windDirection deg="315" code="NW" name="Northwest"></windDirection>
Expand All @@ -75,7 +75,7 @@ public static function forecastXML()
<humidity value="97" unit="%"></humidity>
<clouds value="overcast clouds" all="92" unit="%"></clouds>
</time>
<time day="' . date('Y-m-d') . '">
<time day="' . date('Y-m-d', time() + 3600) . '">
<symbol number="500" name="light rain" var="10d"></symbol>
<precipitation value="0.24" type="rain"></precipitation>
<windDirection deg="253" code="WSW" name="West-southwest"></windDirection>
Expand Down
11 changes: 2 additions & 9 deletions tests/OpenWeatherMap/WeatherForecastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,12 @@ public function testCurrent()

public function testNext()
{
$this->forecast->rewind();
$this->forecast->next();
$result = $this->forecast->valid();

$this->assertFalse($result);
$this->assertTrue($this->forecast->valid());
}

public function testValid()
{
$this->forecast->rewind();
$this->forecast->next();
$result = $this->forecast->valid();

$this->assertFalse($result);
$this->assertTrue($this->forecast->valid());
}
}

0 comments on commit 92edee8

Please sign in to comment.