aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/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
commitaabcc562d7ad7266b6b1e338a14a19224c1169df (patch)
tree58f415db1e75c76a0ed94a4be3309237a56df90a /lib/js
parente13be030430beb6bafa1d96b1bbaf7adc728cd45 (diff)
Regenerate proper Autotools files; fix JS stringToTime and add stringToTime_error
Diffstat (limited to 'lib/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;
+ }
}