changeset 1487:290de2dcecf6

Add client-side Basis.now and pretty-printing of times
author Adam Chlipala <adam@chlipala.net>
date Wed, 06 Jul 2011 08:35:31 -0400
parents 7f8ddcf12b20
children e2611b5dafce
files lib/js/urweb.js src/jscomp.sml src/settings.sml
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Sun Jul 03 16:50:17 2011 -0400
+++ b/lib/js/urweb.js	Wed Jul 06 08:35:31 2011 -0400
@@ -93,6 +93,19 @@
 }
 
 
+// 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) {
--- a/src/jscomp.sml	Sun Jul 03 16:50:17 2011 -0400
+++ b/src/jscomp.sml	Wed Jul 06 08:35:31 2011 -0400
@@ -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 @@
                                 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
 
--- a/src/settings.sml	Sun Jul 03 16:50:17 2011 -0400
+++ b/src/settings.sml	Wed Jul 06 08:35:31 2011 -0400
@@ -248,7 +248,11 @@
                           ("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)