json-time-0.1.0.0: json + time
Safe HaskellNone
LanguageHaskell2010

Codec.JSON.Encoder.Time

Description

Functions for encoding common time formats in RFC 8259 JSONs.

Synopsis

Calendar

year :: Year -> Encoder Source #

Encode a year as a JSON string in ISO 8601 extended [-…y]yyyy format

Compatible with RFC 3339 if the year is in the \([0,10000)\) interval.

quarter :: Quarter -> Encoder Source #

Encode a year quarter as a JSON string in [-…y]yyyy-Qq format.

Note that year quarters are not defined by ISO 8601, this is an informal convention.

Month

month :: Month -> Encoder Source #

Encode a month date as a JSON string, in ISO 8601 extended [-…y]yyyy-mm format.

RFC 3339 compatibility matches that of the year function.

monthDate :: Day -> Encoder Source #

Encode a month date as a JSON string in ISO 8601 extended [-…y]yyyy-mm-dd format.

RFC 3339 compatibility matches that of the year function.

Week

weekDate :: Day -> Encoder Source #

Encode a week date as a JSON string in ISO 8601 extended [-…y]yyyy-Www-d format.

Ordinal

ordinalDate :: Day -> Encoder Source #

Encode an ordinal date as a JSON string in ISO 8601 extended [-…y]yyyy-ddd format.

Time of day

timeOfDay :: TimeOfDay -> Encoder Source #

Encode a time of day as a JSON string in RFC 3339 hh:mm:ss[.s…] format.

Local

localTime :: LocalTime -> Encoder Source #

Encode a local time as a JSON string in ISO 8601 extended [-…y]yyyy-mm-ddThh:mm:ss[.s…] format.

RFC 3339 compatibility matches that of the year function.

Zoned

utcTime :: UTCTime -> Encoder Source #

Encode a UTC time as a JSON string in ISO 8601 extended [-…y]yyyy-mm-ddThh:mm:ss[.s…]Z format.

RFC 3339 compatibility matches that of the year function.

timeZone :: TimeZone -> Encoder Source #

Encode a time zone as a JSON string in ISO 8601 extended ±[…h]hh:mm format.

Compatible with RFC 3339 if the minute offset from UTC is in the \((-24 \cdot 60, 24 \cdot 60)\) interval.

zonedTime :: ZonedTime -> Encoder Source #

Encode a zoned time as a JSON string in ISO 8601 extended [-…y]yyyy-mm-ddThh:mm:ss[.s…]±[…h]hh:mm format.

RFC 3339 compatibility matches that of both the year and timeZone functions.