]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/W3CDateTime.hs
Resurrection from bitrot
[Rakka.git] / Rakka / W3CDateTime.hs
index 85af47a8e7f54feba299eef30d3dd5015ed6a9dd..4ec4738113b5e0d354349611d57c7648d3361df0 100644 (file)
@@ -1,9 +1,9 @@
+-- FIXME: use time-w3c
 module Rakka.W3CDateTime
     ( formatW3CDateTime
     , parseW3CDateTime
     )
     where
-
 import           Control.Monad
 import           Data.Time
 import           Prelude hiding (min)
@@ -23,13 +23,13 @@ formatW3CDateTime zonedTime
                 timeOfDay          = localTimeOfDay localTime
                 (secInt, secFrac)  = properFraction (todSec timeOfDay)
             in
-              (printf "%04d-%02d-%02dT%02d:%02d:%02d"
-                      year
-                      month
-                      day
-                      (todHour timeOfDay)
-                      (todMin timeOfDay)
-                      (secInt :: Int))
+              printf "%04d-%02d-%02dT%02d:%02d:%02d"
+                     year
+                     month
+                     day
+                     (todHour timeOfDay)
+                     (todMin timeOfDay)
+                     (secInt :: Int)
               ++
               (if secFrac == 0
                then ""
@@ -38,9 +38,9 @@ formatW3CDateTime zonedTime
       formatTimeZone :: TimeZone -> String
       formatTimeZone tz
           = case timeZoneMinutes tz of
-              offset | offset <  0 -> '-':(showTZ $ negate offset)
+              offset | offset <  0 -> '-' : (showTZ $ negate offset)
                      | offset == 0 -> "Z"
-                     | otherwise   -> '+':(showTZ offset)
+                     | otherwise   -> '+' : showTZ offset
       
       showTZ :: Int -> String   
       showTZ offset
@@ -50,7 +50,7 @@ formatW3CDateTime zonedTime
               show2 hour ++ ":" ++ show2 minute
             
       show2 :: Int -> String
-      show2 n | n < 10    = '0':(show n)
+      show2 n | n < 10    = '0' : show n
               | otherwise = show n
 
 
@@ -77,11 +77,11 @@ w3cDateTime = do year <- liftM read (count 4 digit)
                  return zonedTime
     where
       time :: Parser (Int, Int, Double, Int)
-      time = do char 'T'
+      time = do _      <- char 'T'
                 hour   <- liftM read (count 2 digit)
-                char ':'
+                _      <- char ':'
                 min    <- liftM read (count 2 digit)
-                sec    <- option 0 $ do char ':'
+                sec    <- option 0 $ do _       <- char ':'
                                         secInt  <- count 2 digit
                                         secFrac <- option "" $ do c  <- char '.'
                                                                   cs <- many1 digit
@@ -93,7 +93,7 @@ w3cDateTime = do year <- liftM read (count 4 digit)
                                     <|>
                                     (char '-' >> return (-1))
                             h    <- liftM read (count 2 digit)
-                            char ':'
+                            _    <- char ':'
                             m    <- liftM read (count 2 digit)
                             return $ sign * h * 60 + m)
                 return (hour, min, sec, offMin)
\ No newline at end of file