Merge 97b0c53bc8
into a1cb044262
This commit is contained in:
19
assets/js/datelocale.ts
Normal file
19
assets/js/datelocale.ts
Normal file
@ -0,0 +1,19 @@
|
||||
function formatDate(date: string | null) {
|
||||
if (!date) return date;
|
||||
return new Intl.DateTimeFormat(process.env.lang_code, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(new Date(date));
|
||||
}
|
||||
|
||||
if ('Intl' in window) {
|
||||
window.addEventListener('load', () => {
|
||||
for(const span of [...document.querySelectorAll('.localizable-date')]) {
|
||||
const localizedDate = formatDate(span.getAttribute('title'));
|
||||
if (localizedDate) {
|
||||
span.innerHTML = localizedDate;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user