mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #7162
This commit is contained in:
@@ -120,7 +120,18 @@ if (typeof window !== 'undefined') {
|
|||||||
$.timeago.settings.allowFuture = true;
|
$.timeago.settings.allowFuture = true;
|
||||||
var userLang = config.userLang.replace('_', '-');
|
var userLang = config.userLang.replace('_', '-');
|
||||||
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 formatFn;
|
||||||
|
if (typeof Intl === 'undefined') {
|
||||||
|
formatFn = function (date) {
|
||||||
|
return date.toLocaleString(userLang, options);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
var dtFormat = new Intl.DateTimeFormat(userLang, options);
|
var dtFormat = new Intl.DateTimeFormat(userLang, options);
|
||||||
|
formatFn = function (date) {
|
||||||
|
return dtFormat.format(date);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var iso;
|
var iso;
|
||||||
var date;
|
var date;
|
||||||
$.fn.timeago = function () {
|
$.fn.timeago = function () {
|
||||||
@@ -134,7 +145,7 @@ if (typeof window !== 'undefined') {
|
|||||||
this.setAttribute('datetime', iso);
|
this.setAttribute('datetime', iso);
|
||||||
date = new Date(iso);
|
date = new Date(iso);
|
||||||
if (!isNaN(date)) {
|
if (!isNaN(date)) {
|
||||||
this.textContent = dtFormat.format(date);
|
this.textContent = formatFn(date);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user