Internet Message Format Date & Time

Elm packageBuild Status

Convert Internet Message Format date and time strings to and from POSIX times.

Valid strings include date and time strings conforming to RFC5322, as well as the obsolete RFC2822 and RFC822, however obsolete formats are interpreted following RFC5322 recommendations.

Produced strings conform to RFC5322, without using any obsolete format.

These date and time formats are found for example in SMTP and RSS.

New Internet protocols should most likely NOT use this format.
Alternatives are POSIX times as advised here or ISO 8601 following recommendations from RFC3339.

Examples

import Imf.DateTime
import Time

epoch : Time.Posix
epoch = Time.millisToPosix 0

Imf.DateTime.fromPosix Time.utc epoch
--> "Thu, 01 Jan 1970 00:00:00 +0000"

Imf.DateTime.toPosix "1 Jan 70 00:00:00 GMT"
--> Ok epoch

est : Time.Zone
est = Time.customZone -300 []

Imf.DateTime.toPosix "11 Jan 2013 08:11:00 GMT"
    |>  Result.map (Imf.DateTime.fromPosix est)
--> Ok ("Fri, 11 Jan 2013 03:11:00 -0500")