after first pass of timeago, title contains "21 lis 2018, 10:30" which is invalid for new Date(), check before passing it to format
v1.18.x
Barış Soner Uşaklı 6 years ago
parent 01c942fc39
commit dc670a7bb5

@ -122,6 +122,7 @@ if (typeof window !== 'undefined') {
var options = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' }; var options = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
var dtFormat = new Intl.DateTimeFormat(userLang, options); var dtFormat = new Intl.DateTimeFormat(userLang, options);
var iso; var iso;
var date;
$.fn.timeago = function () { $.fn.timeago = function () {
var els = $(this); var els = $(this);
// Convert "old" format to new format (#5108) // Convert "old" format to new format (#5108)
@ -131,7 +132,10 @@ if (typeof window !== 'undefined') {
return; return;
} }
this.setAttribute('datetime', iso); 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); timeagoFn.apply(this, arguments);

Loading…
Cancel
Save