summaryrefslogtreecommitdiff
path: root/www/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/utils.js')
-rw-r--r--www/js/utils.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/www/js/utils.js b/www/js/utils.js
index 8a7ee9c..b8bfee7 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -53,17 +53,20 @@ weekday[6] = 'Samstag';
var weekday_short = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
function format_datetime(d) {
- if(Object.prototype.toString.call(d) === '[object Date]') {
- var datetimestr = weekday_short[d.getDay()];
- datetimestr += ' ' + Number(d.getDate()).pad(2);
- datetimestr += '.' + Number(d.getMonth() + 1).pad(2);
- datetimestr += '.' + d.getFullYear();
- datetimestr += ' ' + Number(d.getHours()).pad(2);
- datetimestr += ':' + Number(d.getMinutes()).pad(2);
- datetimestr += ':' + Number(d.getSeconds()).pad(2);
- return datetimestr;
+ if(Object.prototype.toString.call(d) !== '[object Date]') {
+ return d;
}
- return d;
+ if (d.toString() === 'Invalid Date') {
+ return d;
+ }
+ var datetimestr = weekday_short[d.getDay()];
+ datetimestr += ' ' + Number(d.getDate()).pad(2);
+ datetimestr += '.' + Number(d.getMonth() + 1).pad(2);
+ datetimestr += '.' + d.getFullYear();
+ datetimestr += ' ' + Number(d.getHours()).pad(2);
+ datetimestr += ':' + Number(d.getMinutes()).pad(2);
+ datetimestr += ':' + Number(d.getSeconds()).pad(2);
+ return datetimestr;
}
function msToTimeString(time) {