Skip to content

dmy/elm-imf-date-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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