cleaned up units in weather

This commit is contained in:
Harald Hope 2018-05-11 20:08:48 -07:00
parent 5ea6a66474
commit 04d08bdc4c

10
inxi
View file

@ -13897,7 +13897,7 @@ sub wind_output {
$gust_mph = undef if $gust_mph && $mph && $mph eq $gust_mph; $gust_mph = undef if $gust_mph && $mph && $mph eq $gust_mph;
$gust_ms = undef if $gust_ms && $ms && $ms eq $gust_ms; $gust_ms = undef if $gust_ms && $ms && $ms eq $gust_ms;
# calculate and round, order matters so that rounding only happens after math done # calculate and round, order matters so that rounding only happens after math done
$ms = 0.44704 * $mph if $mph && !$ms; $ms = sprintf("%.1f", $ms ) if $ms; # very low mph speeds yield 0, which is wrong
$mph = $ms * 2.23694 if $ms && !$mph; $mph = $ms * 2.23694 if $ms && !$mph;
$kmh = sprintf("%.0f", 18 * $ms / 5) if $ms; $kmh = sprintf("%.0f", 18 * $ms / 5) if $ms;
$ms = sprintf("%.0f", $ms ) if $ms; $ms = sprintf("%.0f", $ms ) if $ms;
@ -13913,10 +13913,10 @@ sub wind_output {
} }
elsif ($mph && $direction ){ elsif ($mph && $direction ){
if ( $weather_unit eq 'cf' ){ if ( $weather_unit eq 'cf' ){
$result = "from $direction at $ms $m_unit ($kmh $km_unit; $mph $i_unit)"; $result = "from $direction at $ms $m_unit ($kmh $km_unit, $mph $i_unit)";
} }
elsif ( $weather_unit eq 'fc' ){ elsif ( $weather_unit eq 'fc' ){
$result = "from $direction at $mph $i_unit ($ms $m_unit; $kmh $km_unit)"; $result = "from $direction at $mph $i_unit ($ms $m_unit, $kmh $km_unit)";
} }
elsif ( $weather_unit eq 'c' ){ elsif ( $weather_unit eq 'c' ){
$result = "from $direction at $ms $m_unit ($kmh $km_unit)"; $result = "from $direction at $ms $m_unit ($kmh $km_unit)";
@ -13926,10 +13926,10 @@ sub wind_output {
} }
if ($gust_mph){ if ($gust_mph){
if ( $weather_unit eq 'cf' ){ if ( $weather_unit eq 'cf' ){
$result .= ". Gusting to $ms $m_unit ($kmh $km_unit; $mph $i_unit)"; $result .= ". Gusting to $ms $m_unit ($kmh $km_unit, $mph $i_unit)";
} }
elsif ( $weather_unit eq 'fc' ){ elsif ( $weather_unit eq 'fc' ){
$result .= ". Gusting to $mph $i_unit ($ms $m_unit; $kmh $km_unit)"; $result .= ". Gusting to $mph $i_unit ($ms $m_unit, $kmh $km_unit)";
} }
elsif ( $weather_unit eq 'c' ){ elsif ( $weather_unit eq 'c' ){
$result .= ". Gusting to $ms $m_unit ($kmh $km_unit)"; $result .= ". Gusting to $ms $m_unit ($kmh $km_unit)";