4 -- |This module provides functions to parse and format RFC 733 date
7 -- The syntax is as follows:
9 -- > date-time ::= [ day-of-week ", " ] date SP time ("-" | SP) zone
10 -- > day-of-week ::= "Monday" | "Mon" | "Tuesday" | "Tue"
11 -- > | "Wednesday" | "Wed" | "Thursday" | "Thu"
12 -- > | "Friday" | "Fri" | "Saturday" | "Sat"
13 -- > | "Sunday" | "Sun"
14 -- > date ::= day ("-" | SP) month ("-" | SP) year
16 -- > year ::= 2DIGIT | 4DIGIT
17 -- > month ::= "January" | "Jan" | "February" | "Feb"
18 -- > | "March" | "Mar" | "April" | "Apr"
19 -- > | "May" | "June" | "Jun"
20 -- > | "July" | "Jul" | "August" | "Aug"
21 -- > | "September" | "Sep" | "October" | "Oct"
22 -- > | "November" | "Nov" | "December" | "Dec"
23 -- > time ::= hour [ ":" ] minute [ [ ":" ] second ]
25 -- > minute ::= 2DIGIT
26 -- > second ::= 2DIGIT
27 -- > zone ::= "GMT" ; Universal Time
28 -- > | "NST" ; Newfoundland: -3:30
29 -- > | "AST" | "ADT" ; Atlantic : -4 / -3
30 -- > | "EST" | "EDT" ; Eastern : -5 / -4
31 -- > | "CST" | "CDT" ; Central : -6 / -5
32 -- > | "MST" | "MDT" ; Mountain : -7 / -6
33 -- > | "PST" | "PDT" ; Pacific : -8 / -7
34 -- > | "YST" | "YDT" ; Yukon : -9 / -8
35 -- > | "HST" | "HDT" ; Haw/Ala : -10 / -9
36 -- > | "BST" | "BDT" ; Bering : -11 / -10
42 -- > | ("+" | "-") 4DIGIT ; Local diff: HHMM
43 module Data.Time.RFC733
53 import Data.Ascii (Ascii)
54 import qualified Data.Ascii as A
55 import qualified Data.Attoparsec.Char8 as P
57 import Data.Time.RFC733.Internal
58 import Prelude.Unicode
60 -- |Convert a 'ZonedTime' to RFC 733 date and time string.
61 toAscii ∷ ZonedTime → Ascii
62 toAscii = A.fromAsciiBuilder ∘ toAsciiBuilder
64 -- |Parse an RFC 733 date and time string. When the string can't be
65 -- parsed, it returns @'Left' err@.
66 fromAscii ∷ Ascii → Either String ZonedTime
67 fromAscii = P.parseOnly p ∘ A.toByteString
69 p = do zt ← rfc733DateAndTime