@@ -4,6 +4,11 @@
4-- locale formatting or something.
4-- locale formatting or something.
5module Date where
5module Date where
7+import Native.Date as Native
7-- Represents the days of the week.
12-- Represents the days of the week.
8data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
13data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
@@ -14,37 +19,45 @@ data Month = Jan | Feb | Mar | Apr
15-- Attempt to read a date from a string.
20-- Attempt to read a date from a string.
16read : String -> Maybe Date
21read : String -> Maybe Date
18-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
24-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
19-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
25-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
20-- 1990 at 11:45AM this returns the corresponding time.
26-- 1990 at 11:45AM this returns the corresponding time.
21toTime : Date -> Time
27toTime : Date -> Time
28+toTime = Native.toTime
23-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
30-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
24-- this returns the integer `1990`.
31-- this returns the integer `1990`.
25−year : Date -> Int
32+year : Date -> Int
27-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
35-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
28-- this returns the Month `Jun` as defined below.
36-- this returns the Month `Jun` as defined below.
29month : Date -> Month
37month : Date -> Month
30−
38+month = Native.month
32-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
40-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
33-- this returns the integer `23`.
41-- this returns the integer `23`.
34−day : Date -> Int
42+day : Date -> Int
36-- Extract the day of the week for a given date. Given the date 23 June
45-- Extract the day of the week for a given date. Given the date 23 June
37-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
46-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
38dayOfWeek : Date -> Day
47dayOfWeek : Date -> Day
48+dayOfWeek = Native.dayOfWeek
40-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
50-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
41-- this returns the integer `11`.
51-- this returns the integer `11`.
42−hour : Date -> Int
52+hour : Date -> Int
44-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
55-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
45-- this returns the integer `45`.
56-- this returns the integer `45`.
46minute : Date -> Int
57minute : Date -> Int
58+minute = Native.minute
48-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
60-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
49-- this returns the integer `0`.
61-- this returns the integer `0`.
50second : Date -> Int
62second : Date -> Int
63+second = Native.second