From aabcc562d7ad7266b6b1e338a14a19224c1169df Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 18 Nov 2011 17:17:22 -0500 Subject: Regenerate proper Autotools files; fix JS stringToTime and add stringToTime_error --- lib/js/urweb.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/js') 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; + } } -- cgit v1.2.3