[Web] Do not print invalid date

master
andryyy 2021-02-12 21:22:05 +01:00
parent 02fd0b03f6
commit fee4b50b9b
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
1 changed files with 13 additions and 9 deletions

View File

@ -6,6 +6,7 @@ $(document).ready(function() {
var started_s_ago = parseInt($(this).text(), 10); var started_s_ago = parseInt($(this).text(), 10);
if (typeof started_s_ago != 'NaN') { if (typeof started_s_ago != 'NaN') {
var started_date = new Date((ts_now - started_s_ago) * 1000); var started_date = new Date((ts_now - started_s_ago) * 1000);
if (started_date instanceof Date && !isNaN(started_date)) {
var started_local_date = started_date.toLocaleDateString(undefined, { var started_local_date = started_date.toLocaleDateString(undefined, {
year: "numeric", year: "numeric",
month: "2-digit", month: "2-digit",
@ -15,6 +16,9 @@ $(document).ready(function() {
second: "2-digit" second: "2-digit"
}); });
$(this).text(started_local_date); $(this).text(started_local_date);
} else {
$(this).text('-');
}
} }
}); });
// Parse general dates // Parse general dates