Permalink
Browse files

Guard against incomplete data in the MetOffice feed, if a period cont…

…ains no data then skip over it
  • Loading branch information...
1 parent a9f18c6 commit b379de3fc961fb8118ccc02caa327d8e92351f29 @stuartm stuartm committed Aug 1, 2012
@@ -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
@@ -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));

0 comments on commit b379de3

Please sign in to comment.