summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-11-18 17:17:22 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-11-18 17:17:22 -0500
commit69e08bd046195515eed94d425ebd4cf549d5a549 (patch)
tree58f415db1e75c76a0ed94a4be3309237a56df90a /lib/js/urweb.js
parenta62d5a46d2c1b8e44fc60862205a07beef499742 (diff)
Regenerate proper Autotools files; fix JS stringToTime and add stringToTime_error
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index fab15f35..8664ec9a 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -112,12 +112,13 @@ function round(n) {
}
-// 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 @@ function addSeconds(tm, n) {
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;
+ }
}