From 2db05384549f463a4a95076e63ddf8acad1c7b33 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Thu, 11 Sep 2014 15:01:56 +1000 Subject: Occasionally there is no wind and a METAR report gives simply, "Wind: 0" --- src/Plugins/Monitors/Weather.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Monitors/Weather.hs b/src/Plugins/Monitors/Weather.hs index 8119842..7cf68de 100644 --- a/src/Plugins/Monitors/Weather.hs +++ b/src/Plugins/Monitors/Weather.hs @@ -77,6 +77,17 @@ pTime = do y <- getNumbersAsString char ' ' return (y, m, d ,h:hh:":"++mi:mimi) +-- Occasionally there is no wind and a METAR report gives simply, "Wind: 0" +pWind0 :: + ( + String -- cardinal direction + , String -- azimuth direction + , String -- speed (MPH) + , String -- speed (knot) + ) +pWind0 = + ("∘", "0", "0", "0") + pWind :: Parser ( String -- cardinal direction @@ -86,6 +97,8 @@ pWind :: ) pWind = let tospace = manyTill anyChar (char ' ') + wind0 = do manyTill skipRestOfLine (string "Wind: 0") + return pWind0 wind = do manyTill skipRestOfLine (string "Wind: from the ") cardinal <- tospace char '(' @@ -96,7 +109,7 @@ pWind = knot <- tospace manyTill anyChar newline return (cardinal, azimuth, mph, knot) - in try wind <|> return ("a", "b", "c", "d") + in try wind0 <|> wind pTemp :: Parser (Int, Int) pTemp = do let num = digit <|> char '-' <|> char '.' -- cgit v1.2.3