项目作者: dmy

项目描述 :
Convert between Internet Message Format date & time strings and elm/time Time.Posix
高级语言: Elm
项目地址: git://github.com/dmy/elm-imf-date-time.git
创建时间: 2019-04-07T22:47:04Z
项目社区:https://github.com/dmy/elm-imf-date-time

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Internet Message Format Date & Time

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

  1. 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

  1. import Imf.DateTime
  2. import Time
  3. epoch : Time.Posix
  4. epoch = Time.millisToPosix 0
  5. Imf.DateTime.fromPosix Time.utc epoch
  6. --> "Thu, 01 Jan 1970 00:00:00 +0000"
  7. Imf.DateTime.toPosix "1 Jan 70 00:00:00 GMT"
  8. --> Ok epoch
  9. est : Time.Zone
  10. est = Time.customZone -300 []
  11. Imf.DateTime.toPosix "Fri, 11 Jan 2013 08:11:00 GMT"
  12. |> Result.map (Imf.DateTime.fromPosix est)
  13. --> Ok ("Fri, 11 Jan 2013 03:11:00 -0500")