Created
December 7, 2015 22:49
-
-
Save danneu/d98fb07074ea1b96c709 to your computer and use it in GitHub Desktop.
Usage: `Current.date ()`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Current where | |
import Native.Current | |
import Time exposing (Time) | |
import Date exposing (Date) | |
-- milliseconds since epoch | |
time : () -> Time | |
time _ = | |
Native.Current.time () | |
date : () -> Date | |
date _ = | |
Native.Current.date () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elm.Native.Current = {}; | |
Elm.Native.Current.make = function(localRuntime) { | |
localRuntime.Native = localRuntime.Native || {}; | |
localRuntime.Native.Current = localRuntime.Native.Current || {}; | |
if (localRuntime.Native.Current.values) { | |
return localRuntime.Native.Current.values; | |
} | |
function time() { | |
return new Date().getTime(); | |
} | |
function date() { | |
return new Date(); | |
} | |
return localRuntime.Native.Current.values = { | |
time: time, | |
date: date, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment