better date formatting

This commit is contained in:
vapormusic 2022-01-29 21:31:18 +07:00
parent 6f35ab6261
commit 5c75379bb1

View file

@ -447,8 +447,13 @@
let formatted = ''
try {formatted = new Intl.DateTimeFormat(this.app.cfg.general.language?.replace('_','-') ?? 'en-US', {day:'numeric',month: 'long', year: 'numeric'}).format(releaseDate);}
catch(e){
// use the format in json instead
if (this.app.getLz('date.format') != null){
formatted = new this.app.getLz('date.format').replace("${d}", releaseDate.getDate()).replace("${m}", releaseDate.getMonth()).replace("${y}", releaseDate.getFullYear());
} else {
formatted = new Intl.DateTimeFormat('en-US', {day:'numeric',month: 'long', year: 'numeric'}).format(releaseDate);
}
}
return prefix + formatted
} catch (e) {
return ""