Skip to content
Convert between Internet Message Format date & time strings and elm/time Time.Posix
Elm
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Imf
tests
.gitignore
.travis.yml
LICENSE
README.md
elm.json

README.md

Internet Message Format Date & Time

Elm package Build Status

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

    elm install dmy/elm-imf-date-time

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 HTTP, 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 "Fri, 11 Jan 2013 08:11:00 GMT"
    |>  Result.map (Imf.DateTime.fromPosix est)
--> Ok ("Fri, 11 Jan 2013 03:11:00 -0500")
You can’t perform that action at this time.