]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/RFC1123DateTime.hs
The parser now returns unboxed tuple.
[Lucu.git] / Network / HTTP / Lucu / RFC1123DateTime.hs
index 3be2dd414b0bd67ba39166a6d9d95c2395977c16..2cd06cc9cac7f79f2870e3da1847c57f8e089350 100644 (file)
@@ -9,12 +9,9 @@ module Network.HTTP.Lucu.RFC1123DateTime
     where
 
 import           Control.Monad
-import qualified Data.ByteString.Lazy.Char8 as B
-import           Data.ByteString.Lazy.Char8 (ByteString)
 import           Network.HTTP.Lucu.Format
 import           Network.HTTP.Lucu.Parser
 import           System.Time
-import           System.Locale
 
 month :: [String]
 month =  ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
@@ -40,7 +37,7 @@ formatRFC1123DateTime time
       fmtDec 2 (ctMin    time)
       ++ ":"  ++
       fmtDec 2 (ctSec    time)
-      ++ ":"  ++
+      ++ " "  ++
       id       (ctTZName time)
       
 
@@ -68,17 +65,17 @@ formatHTTPDateTime time
 parseHTTPDateTime :: String -> Maybe ClockTime
 parseHTTPDateTime src
     = case parseStr httpDateTime src of
-        (Success ct, _) -> Just ct
-        _               -> Nothing
+        (# Success ct, _ #) -> Just ct
+        (# _         , _ #) -> Nothing
 
 
 httpDateTime :: Parser ClockTime
-httpDateTime = do foldl (<|>) (fail "") (map string week)
+httpDateTime = do foldl (<|>) failP (map string week)
                   char ','
                   char ' '
                   day  <- liftM read (count 2 digit)
                   char ' '
-                  mon  <- foldl (<|>) (fail "") (map tryEqToFst (zip month [1..]))
+                  mon  <- foldl (<|>) failP (map tryEqToFst (zip month [1..]))
                   char ' '
                   year <- liftM read (count 4 digit)
                   char ' '