Skip to content

Instantly share code, notes, and snippets.

@danneu
Created December 7, 2015 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danneu/d98fb07074ea1b96c709 to your computer and use it in GitHub Desktop.
Save danneu/d98fb07074ea1b96c709 to your computer and use it in GitHub Desktop.
Usage: `Current.date ()`
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 ()
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