4 -- |Internal functions for "Data.Time.HTTP".
5 module Data.Time.HTTP.Internal
10 import Control.Applicative
11 import Data.Ascii (AsciiBuilder)
12 import Data.Attoparsec.Char8
14 import qualified Data.Time.RFC1123.Internal as RFC1123
15 import Data.Time.RFC733
16 import Data.Time.Asctime
17 import Prelude.Unicode
19 -- |Parse a date and time string in any formats allowed by HTTP\/1.1
21 httpDateAndTime ∷ Parser UTCTime
23 = choice [ zonedTimeToUTC <$> try RFC1123.rfc1123DateAndTime
24 , zonedTimeToUTC <$> try rfc733DateAndTime
25 , localTimeToUTC utc <$> asctime
28 -- |Convert a 'UTCTime' to RFC 1123 date and time string.
29 toAsciiBuilder ∷ UTCTime → AsciiBuilder
30 toAsciiBuilder = RFC1123.toAsciiBuilder ∘ ut2zt
32 ut2zt ∷ UTCTime → ZonedTime
33 ut2zt = utcToZonedTime gmt
36 gmt = TimeZone 0 False "GMT"