dmy / elm-imf-date-time

Convert between Internet Message Format date & time strings and elm/time Time.Posix

Home Page:https://package.elm-lang.org/packages/dmy/elm-imf-date-time/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internet Message Format Date & Time

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

About

Convert between Internet Message Format date & time strings and elm/time Time.Posix

https://package.elm-lang.org/packages/dmy/elm-imf-date-time/latest/

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Elm 100.0%