diff lib/js/urweb.js @ 1599:252e05bf199d

Regenerate proper Autotools files; fix JS stringToTime and add stringToTime_error
author Adam Chlipala <adam@chlipala.net>
date Fri, 18 Nov 2011 17:17:22 -0500
parents e283ca05c829
children c6cc104a47ac
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Nov 17 17:19:10 2011 +0100
+++ b/lib/js/urweb.js	Fri Nov 18 17:17:22 2011 -0500
@@ -112,12 +112,13 @@
 }
 
 
-// Time
+// Time, represented as counts of microseconds since the epoch
 
 function showTime(tm) {
     var newDate = new Date();
     newDate.setTime(tm / 1000);
-    return newDate.toUTCString();
+    var r = newDate.toUTCString();
+    return r;
 }
 
 function now() {
@@ -136,9 +137,24 @@
     return tm + n * 1000000;
 }
 
-function stringToTime(string){
-   return  Date.parse(string)  // returns milliseconds and we need microseconds
-                      * 1000;
+function stringToTime_error(string) {
+    var t = Date.parse(string);
+    if (isNaN(t))
+        onFail("Invalid date string: " + string);
+    else
+        return t * 1000;
+}
+
+function stringToTime(string) {
+    try {
+        var t = Date.parse(string);
+        if (isNaN(t))
+            return null;
+        else
+            return t * 1000;
+    } catch (e) {
+        return null;
+    }
 }