+++ /dev/null
-{-# LANGUAGE
- UnicodeSyntax
- #-}
--- |Internal functions for "Data.Time.HTTP".
-module Data.Time.HTTP.Internal
- ( httpDateAndTime
- , toAsciiBuilder
- )
- where
-import Control.Applicative
-import Data.Ascii (AsciiBuilder)
-import Data.Attoparsec.Char8
-import Data.Convertible.Base
-import Data.Tagged
-import Data.Time
-import Data.Time.RFC1123
-import Data.Time.RFC733
-import Data.Time.Asctime
-import Prelude.Unicode
-
--- |Parse a date and time string in any formats allowed by HTTP\/1.1
--- (RFC 2616).
-httpDateAndTime ∷ Parser UTCTime
-httpDateAndTime
- = choice [ zonedTimeToUTC <$> try rfc1123DateAndTime
- , zonedTimeToUTC <$> try rfc733DateAndTime
- , localTimeToUTC utc <$> asctime
- ]
-
--- |Convert a 'UTCTime' to RFC 1123 date and time string.
-toAsciiBuilder ∷ UTCTime → AsciiBuilder
-toAsciiBuilder = untag' ∘ cs ∘ ut2zt
- where
- untag' ∷ Tagged RFC1123 AsciiBuilder → AsciiBuilder
- {-# INLINE CONLIKE untag' #-}
- untag' = untag
-
- ut2zt ∷ UTCTime → ZonedTime
- {-# INLINE ut2zt #-}
- ut2zt = utcToZonedTime gmt
-
- gmt ∷ TimeZone
- {-# INLINE CONLIKE gmt #-}
- gmt = TimeZone 0 False "GMT"