elm-lang/core/2.1.0

NOTE: this package moved to elm/core

NOTE: this package is not compatible with Elm 0.19.1

Date

Library for working with dates. Email the mailing list if you encounter issues with internationalization or locale formatting.

Conversions

fromString : String -> Result String Date

Attempt to read a date from a string.

toTime : Date -> Time

Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e. UNIX time). Given the date 23 June 1990 at 11:45AM this returns the corresponding time.

fromTime : Time -> Date

Take a UNIX time and convert it to a Date.

Extractions

year : Date -> Int

Extract the year of a given date. Given the date 23 June 1990 at 11:45AM this returns the integer 1990.

month : Date -> Month

Extract the month of a given date. Given the date 23 June 1990 at 11:45AM this returns the Month Jun as defined below.

type Month
= Jan
| Feb
| Mar
| Apr
| May
| Jun
| Jul
| Aug
| Sep
| Oct
| Nov
| Dec

Represents the month of the year.

day : Date -> Int

Extract the day of a given date. Given the date 23 June 1990 at 11:45AM this returns the integer 23.

dayOfWeek : Date -> Day

Extract the day of the week for a given date. Given the date 23 June 1990 at 11:45AM this returns the Day Thu as defined below.

type Day
= Mon
| Tue
| Wed
| Thu
| Fri
| Sat
| Sun

Represents the days of the week.

hour : Date -> Int

Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM this returns the integer 11.

minute : Date -> Int

Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM this returns the integer 45.

second : Date -> Int

Extract the second of a given date. Given the date 23 June 1990 at 11:45AM this returns the integer 0.

millisecond : Date -> Int

Extract the millisecond of a given date. Given the date 23 June 1990 at 11:45:30.123AM this returns the integer 123.