Skip to content

Commit

Permalink
Guard against incomplete data in the MetOffice feed, if a period cont…
Browse files Browse the repository at this point in the history
…ains no data then skip over it
  • Loading branch information
stuartm committed Aug 1, 2012
1 parent a9f18c6 commit b379de3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -139,6 +139,10 @@

foreach $item (@{$xml->{DV}->{Location}->{Period}}) {

if (ref($item->{Rep}) ne 'ARRAY') {
next;
}

my ($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($item->{val});
$year += 1900; # Returns year as offset from 1900
$month += 1; # Returns month starting at zero
Expand Down
Expand Up @@ -139,6 +139,10 @@

foreach $item (@{$xml->{DV}->{Location}->{Period}}) {

if (ref($item->{Rep}) ne 'ARRAY') {
next;
}

foreach my $rep (@{$item->{Rep}}) {

my $datetime = DateTime::Format::ISO8601->parse_datetime(substr($item->{val}, 0, -1));
Expand Down

0 comments on commit b379de3

Please sign in to comment.