-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fast parser and formatter for HTTP Date
@package http-date
@version 0.0.13


-- | Fast parser and formatter for HTTP Date.
module Network.HTTP.Date

-- | Translating <a>EpochTime</a> to <a>HTTPDate</a>.
--   
--   <pre>
--   &gt;&gt;&gt; epochTimeToHTTPDate 784887151
--   HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2}
--   </pre>
epochTimeToHTTPDate :: EpochTime -> HTTPDate

-- | Translating <a>HTTPDate</a> to <a>UTCTime</a>.
--   
--   Out-of-range fields are clipped to the nearest valid value, as
--   <a>fromGregorian</a> does. <a>hdWkday</a> is ignored. A second of 60
--   is kept as a leap second only at 23:59. Use <a>httpDateToUTCValid</a>
--   to reject invalid values instead.
--   
--   <pre>
--   &gt;&gt;&gt; httpDateToUTC defaultHTTPDate {hdMonth = 2, hdDay = 31, hdHour = 25}
--   1970-02-28 23:00:00 UTC
--   </pre>
--   
--   Since 0.0.7.
httpDateToUTC :: HTTPDate -> UTCTime

-- | Translating <a>HTTPDate</a> to <a>UTCTime</a> if all fields except
--   <a>hdWkday</a> are valid. A second of 60 is accepted only at 23:59.
--   
--   <pre>
--   &gt;&gt;&gt; httpDateToUTCValid defaultHTTPDate {hdMonth = 2, hdDay = 31}
--   Nothing
--   </pre>
--   
--   Since 0.0.13.
httpDateToUTCValid :: HTTPDate -> Maybe UTCTime

-- | Translating <a>UTCTime</a> to <a>HTTPDate</a>.
--   
--   Since 0.0.7.
utcToHTTPDate :: UTCTime -> HTTPDate

-- | A default value for <a>HTTPDate</a>.
defaultHTTPDate :: HTTPDate

-- | Data structure for HTTP Date. This value should be specified with
--   <a>defaultHTTPDate</a> and its field labels.
data HTTPDate

-- | Parsing HTTP Date. The three formats of RFC 9110 are supported:
--   IMF-fixdate (RFC 1123), the obsolete RFC 850 format and asctime. Dates
--   which do not exist are rejected while the day of the week is not
--   checked against the date.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; parseHTTPDate "Tue, 15 Nov 1994 08:12:31 GMT"
--   Just (HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2})
--   
--   &gt;&gt;&gt; parseHTTPDate "Tuesday, 15-Nov-94 08:12:31 GMT"
--   Just (HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2})
--   
--   &gt;&gt;&gt; parseHTTPDate "Tue Nov 15 08:12:31 1994"
--   Just (HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2})
--   
--   &gt;&gt;&gt; parseHTTPDate "Tue, 31 Feb 1994 08:12:31 GMT"
--   Nothing
--   </pre>
--   
--   A two-digit year of the RFC 850 format is taken as 1970-2069.
parseHTTPDate :: ByteString -> Maybe HTTPDate

-- | Generating HTTP Date in RFC1123 style.
--   
--   <pre>
--   &gt;&gt;&gt; formatHTTPDate defaultHTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2}
--   "Tue, 15 Nov 1994 08:12:31 GMT"
--   </pre>
--   
--   Out-of-range fields are rendered as underscores.
--   
--   <pre>
--   &gt;&gt;&gt; formatHTTPDate defaultHTTPDate {hdYear = 10000, hdMonth = 13, hdDay = 32, hdHour = 24, hdMinute = -1, hdSecond = 61, hdWkday = 0}
--   "___, __ ___ ____ __:__:__ GMT"
--   </pre>
formatHTTPDate :: HTTPDate -> ByteString
