Skip to content

Commit

Permalink
Ignore time periods in the past for the Metoffice 18 hour grabber.
Browse files Browse the repository at this point in the history
The feed doesn't always update on time so it's possible for one or
even two 'historical' time periods to precede the data we're
interested in. This just ignores any forecasts more than 3 hours in
the past, which is the duration of each forecast period.
  • Loading branch information
stuartm committed Jul 29, 2012
1 parent 980be9f commit 5239296
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -22,6 +22,7 @@

use Date::Parse;
use Date::Calc qw(Day_of_Week);
use DateTime;
use DateTime::Format::ISO8601;
use File::Basename;
use lib dirname($0);
Expand Down Expand Up @@ -142,6 +143,12 @@

my $datetime = DateTime::Format::ISO8601->parse_datetime(substr($item->{val}, 0, -1));
$datetime->add( minutes => $rep->{content} );

if ($datetime <= DateTime->now()->subtract( hours => 3 )) # Ignore periods in past
{
next;
}

printf "time-" . $i . "::" . MetOffCommon::format_date($datetime->epoch) . "\n";
my $iconname = "unknown";
switch ($rep->{W}) { # Weather Type
Expand Down

0 comments on commit 5239296

Please sign in to comment.