From bf844972aad8839d430be88b14097fd4cdaec059 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Wed, 12 May 2021 16:34:03 +0200 Subject: Show absolute humidity --- cmd/Print.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmd/Print.hs') diff --git a/cmd/Print.hs b/cmd/Print.hs index dd97c45..7a87023 100644 --- a/cmd/Print.hs +++ b/cmd/Print.hs @@ -6,7 +6,9 @@ module Print import Data.List (intercalate) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Time.LocalTime (TimeZone, minutesToTimeZone, utcToZonedTime) +import Text.Printf (printf) +import Web.OpenWeatherMap.Formulas (absoluteHumidity) import qualified Web.OpenWeatherMap.Types.City as City import qualified Web.OpenWeatherMap.Types.Coord as Coord import qualified Web.OpenWeatherMap.Types.CurrentWeather as CW @@ -26,6 +28,7 @@ printCurrectWeather cw = ", " [ w , showHumidity mainw + , showAbsoluteHumidity mainw , showPressure mainw , showTemp mainw , showWind wind @@ -52,6 +55,7 @@ showForecast tz fc = ", " [ showWeather (FC.weather fc) , showHumidity mainw + , showAbsoluteHumidity mainw , showPressure mainw , showTemp mainw , showWind (FC.wind fc) @@ -86,6 +90,12 @@ showHumidity m = "H " ++ show hm ++ " %" hm :: Int hm = round . Main.humidity $ m +showAbsoluteHumidity :: Main.Main -> String +showAbsoluteHumidity m = "ρ " ++ rho ++ " g/m³" + where + r = absoluteHumidity m + rho = maybe "??" (printf "%0.2f") r + -- https://en.wikipedia.org/wiki/Millimeter_of_mercury showPressure :: Main.Main -> String showPressure m = "P " ++ show p ++ " mmHg" -- cgit v1.2.3