# HG changeset patch # User Adam Chlipala # Date 1309955731 14400 # Node ID 290de2dcecf6a8468808bbc208d61c0ba7641fec # Parent 7f8ddcf12b2067b4d2b90727d8cd60f507275178 Add client-side Basis.now and pretty-printing of times diff -r 7f8ddcf12b20 -r 290de2dcecf6 lib/js/urweb.js --- 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) { diff -r 7f8ddcf12b20 -r 290de2dcecf6 src/jscomp.sml --- 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 diff -r 7f8ddcf12b20 -r 290de2dcecf6 src/settings.sml --- 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)