on master help sign in
Get Date and JS libraries compiling
435822dEvan Czaplicki
libraries/Date.elm+17−4
@@ -4,6 +4,11 @@
4-- locale formatting or something.
4-- locale formatting or something.
5module Date where
5module Date where
6
6
7+import Native.Date as Native
8+import Time
9+
10+data Date = Date
11+
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
9
14
@@ -14,37 +19,45 @@ data Month = Jan | Feb | Mar | Apr
14
19
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
22+read = Native.read
17
23
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
22
29
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
33+year = Native.year
26
34
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
31
39
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
43+day = Native.day
35
44
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
39
49
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
53+hour = Native.hour
43
54
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
47
59
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
libraries/JavaScript.elm+28
@@ -1,26 +1,54 @@
1
1
2module JavaScript where
2module JavaScript where
3
3
4+import Native.JavaScript as Native
5+
6+data JSNumber = JSNumber
7+data JSBool = JSBool
8+data JSString = JSString
9+data JSArray a = JSArray a
10+data JSDomNode = JSDomNode
4
11
5-- Requires that the input array be uniform (all members have the same type)
12-- Requires that the input array be uniform (all members have the same type)
6toList : JSArray a -> [a]
13toList : JSArray a -> [a]
14+toList = Native.toList
15+
7toInt : JSNumber -> Int
16toInt : JSNumber -> Int
17+toInt = Native.toInt
18+
8toFloat : JSNumber -> Float
19toFloat : JSNumber -> Float
20+toFloat = Native.toFloat
21+
9toBool : JSBool -> Bool
22toBool : JSBool -> Bool
23+toBool = Native.toBool
24+
10toString : JSString -> String
25toString : JSString -> String
26+toString = Native.toString
11
27
12
28
13-- Produces a uniform JavaScript array with all members of the same type.
29-- Produces a uniform JavaScript array with all members of the same type.
14fromList : [a] -> JSArray a
30fromList : [a] -> JSArray a
31+fromList = Native.fromList
32+
15fromInt : Int -> JSNumber
33fromInt : Int -> JSNumber
34+fromInt = Native.fromInt
35+
16fromFloat : Float -> JSNumber
36fromFloat : Float -> JSNumber
37+fromFloat = Native.fromFloat
38+
17fromBool : Bool -> JSBool
39fromBool : Bool -> JSBool
40+fromBool = Native.fromBool
41+
18fromString : String -> JSString
42fromString : String -> JSString
43+fromString = Native.fromString
19
44
20
45
21-- Turn an `Element` into a plain old DOM node.
46-- Turn an `Element` into a plain old DOM node.
22fromElement : Element -> JSDomNode
47fromElement : Element -> JSDomNode
48+fromElement = Native.fromElement
23
49
24-- Turn a DOM node into an `Element`. You can resize the node
50-- Turn a DOM node into an `Element`. You can resize the node
25-- using the normal `width` and `height` functions.
51-- using the normal `width` and `height` functions.
26toElement : Int -> Int -> JSDomNode -> Element
52toElement : Int -> Int -> JSDomNode -> Element
53+toElement = Native.toElement
54+