time-http-0.2: Parse and format HTTP/1.1 Date and Time strings

Data.Time.RFC822

Contents

Description

This module provides functions to parse and format RFC 822 date and time formats.

The syntax is as follows:

 date-time   ::= [ day-of-week ", " ] date SP time SP zone
 day-of-week ::= "Mon" | "Tue" | "Wed" | "Thu"
               | "Fri" | "Sat" | "Sun"
 date        ::= day SP month SP year
 day         ::= 2DIGIT
 year        ::= 2DIGIT             ; Yes, only 2 digits.
 month       ::= "Jan" | "Feb" | "Mar" | "Apr"
               | "May" | "Jun" | "Jul" | "Aug"
               | "Sep" | "Oct" | "Nov" | "Dec"
 time        ::= hour ":" minute [ ":" second ]
 hour        ::= 2DIGIT
 minute      ::= 2DIGIT
 second      ::= 2DIGIT
 zone        ::= "UT"  | "GMT"      ; Universal Time
               | "EST" | "EDT"      ; Eastern : -5 / -4
               | "CST" | "CDT"      ; Central : -6 / -5
               | "MST" | "MDT"      ; Mountain: -7 / -6
               | "PST" | "PDT"      ; Pacific : -8 / -7
               | "Z"                ; UT
               | "A"                ;  -1
               | "M"                ; -12
               | "N"                ;  +1
               | "Y"                ; +12
               | ("+" | "-") 4DIGIT ; Local diff: HHMM

Synopsis

Formatting

toAscii :: ZonedTime -> AsciiSource

Convert a ZonedTime to RFC 822 date and time string.

toAsciiBuilder :: ZonedTime -> AsciiBuilderSource

Convert a ZonedTime to RFC 822 date and time string.

Parsing

fromAscii :: Ascii -> Either String ZonedTimeSource

Parse an RFC 822 date and time string. When the string can't be parsed, it returns Left err.

rfc822DateAndTime :: Parser ZonedTimeSource

Parse an RFC 822 date and time string.