Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmy/elm-imf-date-time
Convert between Internet Message Format date & time strings and elm/time Time.Posix
https://github.com/dmy/elm-imf-date-time
date elm imf posix rfc2822 rfc5322 rfc822 time
Last synced: about 1 month ago
JSON representation
Convert between Internet Message Format date & time strings and elm/time Time.Posix
- Host: GitHub
- URL: https://github.com/dmy/elm-imf-date-time
- Owner: dmy
- License: bsd-3-clause
- Created: 2019-04-07T22:47:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-02T08:42:40.000Z (9 months ago)
- Last Synced: 2024-04-02T09:50:11.651Z (9 months ago)
- Topics: date, elm, imf, posix, rfc2822, rfc5322, rfc822, time
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/dmy/elm-imf-date-time/latest/
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Internet Message Format** Date & Time
Convert
[Internet Message Format](https://tools.ietf.org/html/rfc5322#section-3.3)
date and time strings to and from
[POSIX times](https://package.elm-lang.org/packages/elm/time/latest/Time#Posix).```sh
elm install dmy/elm-imf-date-time
```Valid strings include date and time strings conforming to
[RFC5322](https://tools.ietf.org/html/rfc5322#section-3.3),
as well as the obsolete
[RFC2822](https://tools.ietf.org/html/rfc2822#section-3.3)
and
[RFC822](https://www.w3.org/Protocols/rfc822/#z28), however obsolete formats
are interpreted following
[RFC5322 recommendations](https://tools.ietf.org/html/rfc5322#section-4.3).Produced strings conform to
[RFC5322](https://tools.ietf.org/html/rfc5322#section-3.3),
without using any
obsolete format.These date and time formats are found for example in
[HTTP](https://tools.ietf.org/html/rfc7231#section-7.1.1.1),
[SMTP](https://tools.ietf.org/html/rfc5321)
and
[RSS](http://www.rssboard.org/rss-specification).New Internet protocols should most likely NOT use this format.
Alternatives are
[POSIX times](https://package.elm-lang.org/packages/elm/time/latest/Time#Posix)
as advised
[here](https://package.elm-lang.org/packages/rtfeldman/elm-iso8601-date-strings/latest/)
or
[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html)
following recommendations from
[RFC3339](https://tools.ietf.org/html/rfc3339).## Examples
```elm
import Imf.DateTime
import Timeepoch : Time.Posix
epoch = Time.millisToPosix 0Imf.DateTime.fromPosix Time.utc epoch
--> "Thu, 01 Jan 1970 00:00:00 +0000"Imf.DateTime.toPosix "1 Jan 70 00:00:00 GMT"
--> Ok epochest : 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")
```