Force ISO date format option

This commit is contained in:
Natsumi
2022-05-17 17:50:58 +12:00
parent fbd64eb5d5
commit 3e647ed17b
2 changed files with 35 additions and 0 deletions

View File

@@ -19076,9 +19076,11 @@ speechSynthesis.getVoices();
};
$app.data.dtHour12 = configRepository.getBool('VRCX_dtHour12');
$app.data.dtIsoFormat = configRepository.getBool('VRCX_dtIsoFormat');
$app.methods.setDatetimeFormat = async function () {
var currentCulture = await AppApi.CurrentCulture();
var hour12 = configRepository.getBool('VRCX_dtHour12');
var isoFormat = configRepository.getBool('VRCX_dtIsoFormat');
if (typeof this.dtHour12 !== 'undefined') {
if (hour12 !== this.dtHour12) {
configRepository.setBool('VRCX_dtHour12', this.dtHour12);
@@ -19086,6 +19088,12 @@ speechSynthesis.getVoices();
}
var hour12 = this.dtHour12;
}
if (typeof this.dtIsoFormat !== 'undefined') {
if (isoFormat !== this.dtIsoFormat) {
configRepository.setBool('VRCX_dtIsoFormat', this.dtIsoFormat);
}
var isoFormat = this.dtIsoFormat;
}
var formatDate1 = function (date, format) {
if (!date) {
return '-';
@@ -19116,6 +19124,30 @@ speechSynthesis.getVoices();
}
return '-';
};
if (isoFormat) {
formatDate1 = function (date, format) {
if (!date) {
return '-';
}
var dt = new Date(date);
if (format === 'long') {
return dt.toISOString();
} else if (format === 'short') {
return dt
.toLocaleDateString('en-nz', {
month: '2-digit',
day: '2-digit',
hour: 'numeric',
minute: 'numeric',
hourCycle: hour12 ? 'h12' : 'h23'
})
.replace(' AM', 'am')
.replace(' PM', 'pm')
.replace(',', '');
}
return '-';
};
}
Vue.filter('formatDate', formatDate1);
};
$app.methods.setDatetimeFormat();