From dc670a7bb5da0a16fa1677ced0794b5ffff88f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 22 Nov 2018 15:05:22 -0500 Subject: [PATCH] closes #6983 after first pass of timeago, title contains "21 lis 2018, 10:30" which is invalid for new Date(), check before passing it to format --- public/src/overrides.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/src/overrides.js b/public/src/overrides.js index b19b91aecc..4e987e9b85 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -122,6 +122,7 @@ if (typeof window !== 'undefined') { var options = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' }; var dtFormat = new Intl.DateTimeFormat(userLang, options); var iso; + var date; $.fn.timeago = function () { var els = $(this); // Convert "old" format to new format (#5108) @@ -131,7 +132,10 @@ if (typeof window !== 'undefined') { return; } this.setAttribute('datetime', iso); - this.textContent = dtFormat.format(new Date(iso)); + date = new Date(iso); + if (!isNaN(date)) { + this.textContent = dtFormat.format(date); + } }); timeagoFn.apply(this, arguments);