Ticket #8356: script-fixes.patch

File script-fixes.patch, 2.4 KB (added by Alec leamas <gmail: leamas.alec>, 16 years ago)
  • mythweather/scripts/us_nws/ndfd.pl

    Small patches to avoid loss of precision in computed SI values.
    
    From: Alec Leamas <leamas.alec%AT%gmail.com>
    
    
    ---
    
     mythweather/scripts/us_nws/ndfd.pl   |   10 +++++-----
     mythweather/scripts/us_nws/ndfd18.pl |    4 ++--
     2 files changed, 7 insertions(+), 7 deletions(-)
    
    
    diff --git a/mythweather/scripts/us_nws/ndfd.pl b/mythweather/scripts/us_nws/ndfd.pl
    index a69ee2f..ef74938 100755
    a b foreach $time (sort(keys(%$result))) {  
    162162    my $geticon = 0;
    163163    if ($lowindex <= 5 && $result->{$time}->{temperature_minimum}) {
    164164        if ($units eq 'SI') {
    165             $result->{$time}->{temperature_minimum} =
    166                 int ( (5/9) * ($result->{$time}->{temperature_minimum}-32));
     165            $result->{$time}->{'temperature_minimum'} =
     166                 (5/9) * ($result->{$time}->{'temperature_minimum'}-32);
    167167        }
    168         print "low-${lowindex}::$result->{$time}->{temperature_minimum}\n";
     168        printf "low-%d::%.2f\n", $lowindex, $result->{$time}->{'temperature_minimum'} ;
    169169        $lowindex++;
    170170    } elsif ($hiindex <= 5 && $result->{$time}->{temperature_maximum}) {
    171171        if ($units eq 'SI') {
    172172            $result->{$time}->{temperature_maximum} =
    173                 int ( (5/9) * ($result->{$time}->{temperature_maximum}-32));
     173                 (5/9) * ($result->{$time}->{temperature_maximum}-32);
    174174        }
    175         print "high-${hiindex}::$result->{$time}->{temperature_maximum}\n";
     175        printf "high-%d::%.2f\n", $hiindex, $result->{$time}->{temperature_maximum};
    176176        $hiindex++;
    177177        $geticon = 1;
    178178    }
  • mythweather/scripts/us_nws/ndfd18.pl

    diff --git a/mythweather/scripts/us_nws/ndfd18.pl b/mythweather/scripts/us_nws/ndfd18.pl
    index dd0e607..c34ffda 100755
    a b foreach my $time (sort keys %$result) {  
    141141    print "time-${index}::" . UnixDate($time, "%i %p\n");
    142142    if ($units eq 'SI') {
    143143        $result->{$time}->{temperature_hourly} =
    144             int( (5/9) * ($result->{$time}->{temperature_hourly}-32));
     144             (5/9) * ($result->{$time}->{temperature_hourly}-32);
    145145    }
    146     print "temp-${index}::$result->{$time}->{temperature_hourly}\n";
     146    printf "temp-%d::%.2f\n", $index, $result->{$time}->{temperature_hourly};
    147147    print "pop-${index}::$pop12 %\n";
    148148    $icon = $result->{$time}->{'conditions-icon_forecast-NWS'};
    149149    $icon =~ s/.*\/([a-z0-9_]+[.][j][p][g])/$1/;