aboutsummaryrefslogtreecommitdiff
path: root/cmd/Print.hs
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/Print.hs')
-rw-r--r--cmd/Print.hs10
1 files changed, 10 insertions, 0 deletions
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"