on 63243ca help sign in
elk/libraries/Date.elm
72 lines 2.1 kB history raw
2module Date where
4{-| Library for working with dates. Email the mailing list if you encounter
5issues with internationalization or locale formatting.
7# Conversions
8@docs read, toTime
10# Extractions
11@docs year, month, Month, day, dayOfWeek, Day, hour, minute, second
13-}
15import Native.Date
16import Time (Time)
17import Maybe (Maybe)
19data Date = Date
21{-| Represents the days of the week. -}
22data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
24{-| Represents the month of the year. -}
25data Month = Jan | Feb | Mar | Apr
26 | May | Jun | Jul | Aug
27 | Sep | Oct | Nov | Dec
29{-| Attempt to read a date from a string. -}
30read : String -> Maybe Date
31read = Native.Date.read
33{-| Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
34[UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
351990 at 11:45AM this returns the corresponding time. -}
36toTime : Date -> Time
37toTime = Native.Date.toTime
39{-| Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
40this returns the integer `1990`. -}
41year : Date -> Int
42year = Native.Date.year
44{-| Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
45this returns the Month `Jun` as defined below. -}
46month : Date -> Month
47month = Native.Date.month
49{-| Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
50this returns the integer `23`. -}
51day : Date -> Int
52day = Native.Date.day
54{-| Extract the day of the week for a given date. Given the date 23 June
551990 at 11:45AM this returns the Day `Thu` as defined below. -}
56dayOfWeek : Date -> Day
57dayOfWeek = Native.Date.dayOfWeek
59{-| Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
60this returns the integer `11`. -}
61hour : Date -> Int
62hour = Native.Date.hour
64{-| Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
65this returns the integer `45`. -}
66minute : Date -> Int
67minute = Native.Date.minute
69{-| Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
70this returns the integer `0`. -}
71second : Date -> Int
72second = Native.Date.second