summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-07-06 08:35:31 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-07-06 08:35:31 -0400
commita15fb9e7b0144368daa168babb283a664118e87f (patch)
treed19b9706c7ff2c9e023d8ed9a188e75d35598759
parentd56d51bc9a29262682cb08ecd1f6df7886d95850 (diff)
Add client-side Basis.now and pretty-printing of times
-rw-r--r--lib/js/urweb.js13
-rw-r--r--src/jscomp.sml3
-rw-r--r--src/settings.sml6
3 files changed, 19 insertions, 3 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 35a62d76..272ba32b 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -93,6 +93,19 @@ function length(ls) {
}
+// Time
+
+function showTime(tm) {
+ var newDate = new Date();
+ newDate.setTime(tm / 1000);
+ return newDate.toUTCString();
+}
+
+function now() {
+ return (new Date()).getTime() * 1000;
+}
+
+
// Error handling
function whine(msg) {
diff --git a/src/jscomp.sml b/src/jscomp.sml
index d8b2d661..41811e9a 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -1,4 +1,4 @@
-(* Copyright (c) 2008-2010, Adam Chlipala
+(* Copyright (c) 2008-2011, Adam Chlipala
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -646,7 +646,6 @@ fun process file =
val name = case Settings.jsFunc (m, x) of
NONE => (EM.errorAt loc ("Unsupported FFI function "
^ m ^ "." ^ x ^ " in JavaScript");
- app (fn ((m', x'), _) => print (m' ^ "." ^ x' ^ "\n")) (Settings.allJsFuncs ());
"ERROR")
| SOME s => s
diff --git a/src/settings.sml b/src/settings.sml
index 26aaad95..57ab956a 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -248,7 +248,11 @@ val jsFuncsBase = basisM [("alert", "alert"),
("le_time", "le"),
("debug", "alert"),
- ("naughtyDebug", "alert")]
+ ("naughtyDebug", "alert"),
+
+ ("now", "now"),
+ ("timeToString", "showTime"),
+ ("htmlifyTime", "showTime")]
val jsFuncs = ref jsFuncsBase
fun setJsFuncs ls = jsFuncs := foldl (fn ((k, v), m) => M.insert (m, k, v)) jsFuncsBase ls
fun jsFunc x = M.find (!jsFuncs, x)