This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 1.0.1
A reliable way to format dates with elm
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.2
Committed At 2018-02-21 04:53:20 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

README

elm-moment

A reliable way to format dates with elm.

Using the elm package

elm package install ryannhg/elm-moment

What is elm-moment?

If you're coming from Javascript, you might have heard of MomentJS.

MomentJS is a great library for formatting dates!

elm-moment has the same formatting options as Moment, but uses Elm's awesome type system to provide human readable names, and catch typos for you at compile time!

No need to remember the difference between mm and MM and M!

A quick example

import Date
import Moment


-- Create a custom formatter

yourFormatter : Date -> String
yourFormatter =
    Moment.format
        [ Moment.MonthNameFull
        , Moment.Text " "
        , Moment.DayOfMonthSuffix
        , Moment.Text ", "
        , Moment.YearNumber
        ]


-- Using your formatter, format your date as a string!

yourPrettyDate : String
yourPrettyDate =
    case Date.fromString "2018-02-05T00:00:00.000Z" of
        Ok date ->
            yourFormatter date

        Err ->
            "This shouldn't happen..."

Would make yourPrettyDate return:

"February 5th, 2018" : String