diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 26 |
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; + } } |