on master help sign in
Get Date and JS libraries compiling
commit435822d8d84f36256abd56aa69e0b628f9829e2f authorEvan Czaplicki <info@elm-lang.org> dateFri 26 Jul 2013, 11:42 (13 years ago) parent2b2bc08
2 files changed+45−4
libraries/Date.elm+17−4 libraries/JavaScript.elm+28
libraries/Date.elm+17−4
@@ -4,6 +4,11 @@
44-- locale formatting or something.
55module Date where
66
7+import Native.Date as Native
8+import Time
9+
10+data Date = Date
11+
712-- Represents the days of the week.
813data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
914
@@ -14,37 +19,45 @@ data Month = Jan | Feb | Mar | Apr
1419
1520-- Attempt to read a date from a string.
1621read : String -> Maybe Date
22+read = Native.read
1723
1824-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
1925-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
2026-- 1990 at 11:45AM this returns the corresponding time.
2127toTime : Date -> Time
28+toTime = Native.toTime
2229
2330-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
2431-- this returns the integer `1990`.
25−year : Date -> Int
32+year : Date -> Int
33+year = Native.year
2634
2735-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
2836-- this returns the Month `Jun` as defined below.
2937month : Date -> Month
30−
38+month = Native.month
3139
3240-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
3341-- this returns the integer `23`.
34−day : Date -> Int
42+day : Date -> Int
43+day = Native.day
3544
3645-- Extract the day of the week for a given date. Given the date 23 June
3746-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
3847dayOfWeek : Date -> Day
48+dayOfWeek = Native.dayOfWeek
3949
4050-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
4151-- this returns the integer `11`.
42−hour : Date -> Int
52+hour : Date -> Int
53+hour = Native.hour
4354
4455-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
4556-- this returns the integer `45`.
4657minute : Date -> Int
58+minute = Native.minute
4759
4860-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
4961-- this returns the integer `0`.
5062second : Date -> Int
63+second = Native.second
libraries/JavaScript.elm+28
@@ -1,26 +1,54 @@
11
22module JavaScript where
33
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
411
512-- Requires that the input array be uniform (all members have the same type)
613toList : JSArray a -> [a]
14+toList = Native.toList
15+
716toInt : JSNumber -> Int
17+toInt = Native.toInt
18+
819toFloat : JSNumber -> Float
20+toFloat = Native.toFloat
21+
922toBool : JSBool -> Bool
23+toBool = Native.toBool
24+
1025toString : JSString -> String
26+toString = Native.toString
1127
1228
1329-- Produces a uniform JavaScript array with all members of the same type.
1430fromList : [a] -> JSArray a
31+fromList = Native.fromList
32+
1533fromInt : Int -> JSNumber
34+fromInt = Native.fromInt
35+
1636fromFloat : Float -> JSNumber
37+fromFloat = Native.fromFloat
38+
1739fromBool : Bool -> JSBool
40+fromBool = Native.fromBool
41+
1842fromString : String -> JSString
43+fromString = Native.fromString
1944
2045
2146-- Turn an `Element` into a plain old DOM node.
2247fromElement : Element -> JSDomNode
48+fromElement = Native.fromElement
2349
2450-- Turn a DOM node into an `Element`. You can resize the node
2551-- using the normal `width` and `height` functions.
2652toElement : Int -> Int -> JSDomNode -> Element
53+toElement = Native.toElement
54+