Explorar o código

[Web] Do not print invalid date

andryyy %!s(int64=4) %!d(string=hai) anos
pai
achega
fee4b50b9b
Modificáronse 1 ficheiros con 13 adicións e 9 borrados
  1. 13 9
      data/web/js/site/debug.js

+ 13 - 9
data/web/js/site/debug.js

@@ -6,15 +6,19 @@ $(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);
-      var started_local_date = started_date.toLocaleDateString(undefined, {
-        year: "numeric",
-        month: "2-digit",
-        day: "2-digit",
-        hour: "2-digit",
-        minute: "2-digit",
-        second: "2-digit"
-      });
-      $(this).text(started_local_date);
+      if (started_date instanceof Date && !isNaN(started_date)) {
+        var started_local_date = started_date.toLocaleDateString(undefined, {
+          year: "numeric",
+          month: "2-digit",
+          day: "2-digit",
+          hour: "2-digit",
+          minute: "2-digit",
+          second: "2-digit"
+        });
+        $(this).text(started_local_date);
+      } else {
+        $(this).text('-');
+      }
     }
     }
   });
   });
   // Parse general dates
   // Parse general dates