From fd55fb5682cce57e7b6c15c8131a14353955698f Mon Sep 17 00:00:00 2001
From: "Bradley M. Kuhn" <bkuhn@ebb.org>
Date: Sun, 29 Dec 2013 19:12:20 -0500
Subject: Remove state/leading 0's when testing against 'cap:geocode' field in
 output data.

I was getting errors like:
   Argument "NY075" isn't numeric in int at  ../mythtv/mythplugins/mythweather/mythweather/scripts/us_nws/nws-alert.pl line 125.

I analyzed the data and saw that the {int $geo} was being used, which doesn't
work here.  I added a change to remove the state and leading zeros from the
geo, as that seems to match what the NOAA site sends back in the place where
we are testing.
---
 .../mythweather/mythweather/scripts/us_nws/nws-alert.pl    |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/mythplugins/mythweather/mythweather/scripts/us_nws/nws-alert.pl b/mythplugins/mythweather/mythweather/scripts/us_nws/nws-alert.pl
index 2386b3f..496793c 100755
--- a/mythplugins/mythweather/mythweather/scripts/us_nws/nws-alert.pl
+++ b/mythplugins/mythweather/mythweather/scripts/us_nws/nws-alert.pl
@@ -119,15 +119,17 @@ sub getEffectiveWarnings {
     my $tz = new Date::Manip::TZ;
 
     my @dates;
+    $geo =~ s/^[A-Z]*0*//i if (defined $geo);
+    # The geo value is not going have states or leading zeros in the output.
     while ($alert = shift @$alerts) {
         push @dates, $alert->{'updated'};
         while ($info = shift @{$alert->{'entry'}}) {
-            if ($info->{'cap:effective'} && 
-                Date_Cmp($date, $info->{'cap:effective'}) >= 0 &&
-                Date_Cmp($date, $info->{'cap:expires'}) < 0 &&
-                (!$geo || $info->{'cap:geocode'}{int $geo})) {
+            if ($info->{'cap:effective'} and
+                Date_Cmp($date, ParseDate($info->{'cap:effective'})) >= 0 and
+                Date_Cmp($date, ParseDate($info->{'cap:expires'})) < 0 and
+                ( (not defined $geo) or $info->{'cap:geocode'}{$geo})) {
                 push @results, $info;
-            }
+              }
         }
     }
     if (scalar(@dates) > 1) {
-- 
1.7.10.4

