| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.HTTP.Date
Contents
Description
Fast parser and formatter for HTTP Date.
Synopsis
- epochTimeToHTTPDate :: EpochTime -> HTTPDate
- httpDateToUTC :: HTTPDate -> UTCTime
- httpDateToUTCValid :: HTTPDate -> Maybe UTCTime
- utcToHTTPDate :: UTCTime -> HTTPDate
- defaultHTTPDate :: HTTPDate
- data HTTPDate
- parseHTTPDate :: ByteString -> Maybe HTTPDate
- formatHTTPDate :: HTTPDate -> ByteString
Documentation
epochTimeToHTTPDate :: EpochTime -> HTTPDate Source #
Translating EpochTime to HTTPDate.
>>>epochTimeToHTTPDate 784887151HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2}
httpDateToUTC :: HTTPDate -> UTCTime Source #
Translating HTTPDate to UTCTime.
Out-of-range fields are clipped to the nearest valid value, as
fromGregorian does. hdWkday is ignored. A second of 60 is kept
as a leap second only at 23:59. Use httpDateToUTCValid to reject
invalid values instead.
>>>httpDateToUTC defaultHTTPDate {hdMonth = 2, hdDay = 31, hdHour = 25}1970-02-28 23:00:00 UTC
Since 0.0.7.
httpDateToUTCValid :: HTTPDate -> Maybe UTCTime Source #
utcToHTTPDate :: UTCTime -> HTTPDate Source #
Translating UTCTime to HTTPDate.
Since 0.0.7.
defaultHTTPDate :: HTTPDate Source #
A default value for HTTPDate.
Data structure for HTTP Date. This value should be specified
with defaultHTTPDate and its field labels.
Utility functions
parseHTTPDate :: ByteString -> Maybe HTTPDate Source #
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.
>>>:set -XOverloadedStrings>>>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})>>>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})>>>parseHTTPDate "Tue Nov 15 08:12:31 1994"Just (HTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2})>>>parseHTTPDate "Tue, 31 Feb 1994 08:12:31 GMT"Nothing
A two-digit year of the RFC 850 format is taken as 1970-2069.
formatHTTPDate :: HTTPDate -> ByteString Source #
Generating HTTP Date in RFC1123 style.
>>>formatHTTPDate defaultHTTPDate {hdYear = 1994, hdMonth = 11, hdDay = 15, hdHour = 8, hdMinute = 12, hdSecond = 31, hdWkday = 2}"Tue, 15 Nov 1994 08:12:31 GMT"
Out-of-range fields are rendered as underscores.
>>>formatHTTPDate defaultHTTPDate {hdYear = 10000, hdMonth = 13, hdDay = 32, hdHour = 24, hdMinute = -1, hdSecond = 61, hdWkday = 0}"___, __ ___ ____ __:__:__ GMT"