-- > | "Sep" | "Oct" | "Nov" | "Dec"
module Data.Time.Format.HTTP
( HTTP
+ , http
, httpDateAndTime
)
where
import Data.Proxy
import Data.Tagged
import Data.Time
-import Data.Time.Format.Asctime
+import Data.Time.Format.C
import Data.Time.Format.HTTP.Common
import Data.Time.Format.RFC733
import Data.Time.Format.RFC822
-- Tagged "Sun, 06 Nov 1994 08:49:37 GMT"
data HTTP
+-- |The proxy for conversions between ANSI HTTP/1.1 date and time
+-- strings and 'UTCTime'.
+http ∷ Proxy HTTP
+{-# INLINE CONLIKE http #-}
+http = Proxy
+
instance ConvertSuccess UTCTime (Tagged HTTP Ascii) where
{-# INLINE convertSuccess #-}
convertSuccess = (A.fromAsciiBuilder <$>) ∘ cs
= choice [ zonedTimeToUTC <$> try rfc1123DateAndTime
, zonedTimeToUTC <$> try rfc733DateAndTime
, zonedTimeToUTC <$> try rfc822DateAndTime
- , localTimeToUTC utc <$> asctime
+ , localTimeToUTC utc <$> cDateAndTime
]
toAsciiBuilder ∷ UTCTime → AsciiBuilder
{-# INLINE toAsciiBuilder #-}
toAsciiBuilder = flip proxy rfc1123 ∘ cs ∘ ut2zt
where
- rfc1123 ∷ Proxy RFC1123
- {-# INLINE CONLIKE rfc1123 #-}
- rfc1123 = Proxy
-
ut2zt ∷ UTCTime → ZonedTime
{-# INLINE ut2zt #-}
ut2zt = utcToZonedTime gmt