]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/RFC1123DateTime.hs
Optimization
[Lucu.git] / Network / HTTP / Lucu / RFC1123DateTime.hs
index 4d7aa1576a1acf308b99c9e6ae4e36b3520f2a8e..4606bafddce634cb3c7fdf009ba8c27a91c22ae0 100644 (file)
@@ -9,6 +9,7 @@ module Network.HTTP.Lucu.RFC1123DateTime
     where
 
 import           Control.Monad
+import           Data.ByteString.Base (LazyByteString)
 import           Network.HTTP.Lucu.Format
 import           Network.HTTP.Lucu.Parser
 import           System.Time
@@ -19,7 +20,8 @@ month =  ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
 week :: [String]
 week =  ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
 
--- |Format a @CalendarTime@ to RFC 1123 Date and Time string.
+-- |Format a 'System.Time.CalendarTime' to RFC 1123 Date and Time
+-- string.
 formatRFC1123DateTime :: CalendarTime -> String
 formatRFC1123DateTime time
     = time `seq`
@@ -41,8 +43,8 @@ formatRFC1123DateTime time
       id       (ctTZName time)
       
 
--- |Format a @ClockTime@ to HTTP Date and Time. Time zone will be
--- always UTC but prints as GMT.
+-- |Format a 'System.Time.ClockTime' to HTTP Date and Time. Time zone
+-- will be always UTC but prints as GMT.
 formatHTTPDateTime :: ClockTime -> String
 formatHTTPDateTime time
     = time `seq`
@@ -62,11 +64,11 @@ formatHTTPDateTime time
 -- ...but currently this function only supports the RFC 1123
 -- format. This is a violation of RFC 2616 so this should be fixed
 -- later. What a bother!
-parseHTTPDateTime :: String -> Maybe ClockTime
+parseHTTPDateTime :: LazyByteString -> Maybe ClockTime
 parseHTTPDateTime src
-    = case parseStr httpDateTime src of
-        (Success ct, _) -> Just ct
-        _               -> Nothing
+    = case parse httpDateTime src of
+        (# Success ct, _ #) -> Just ct
+        (# _         , _ #) -> Nothing
 
 
 httpDateTime :: Parser ClockTime