time-w3c-0.1.0.1: Parse, format and convert W3C Date and Time

Data.Time.W3C

Description

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.

See: http://www.w3.org/TR/NOTE-datetime

Synopsis

Documentation

data W3CDateTime

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).

Constructors

W3CDateTime 

Instances

format :: Convertible t W3CDateTime => t -> String

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 t

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.