This package provides functionalities to parse and format W3C
Date and Time. The package can also be used to convert it from/to
Data.Time.Calendar.Day
and Data.Time.LocalTime.ZonedTime
.
- data W3CDateTime = W3CDateTime {}
- format :: Convertible t W3CDateTime => t -> String
- parse :: Convertible W3CDateTime t => String -> Maybe t
Documentation
data W3CDateTime Source
W3CDateTime
represents a W3C Date and Time format.
The field w3cYear
is mandatory while other fields are
optional. But you should be careful about combinations of such
optional fields. No combinations are allowed except for the
following list:
- YYYY
- YYYY-MM
- YYYY-MM-DD
- YYYY-MM-DDThh:mmTZD
- YYYY-MM-DDThh:mm:ss.sTZD
This data type is partially ordered so we can't make it an
instance of Ord (e.g. "2010"
and "2010-01"
can't be
compared).
format :: Convertible t W3CDateTime => t -> StringSource
Format W3C Date and Time string from anything convertible to
W3CDateTime
type. The most obvious acceptable type is the
W3CDateTime
itself.
parse :: Convertible W3CDateTime t => String -> Maybe tSource
Parse W3C Date and Time string to anything convertible from
W3CDateTime
type. The most obvious acceptable type is the
W3CDateTime
itself. If the given string is ill-formatted, parse
returns Nothing
.