refactor: make year as A.D.

This commit is contained in:
Methapon Metanipat 2024-09-30 11:09:07 +07:00
parent 1a14a44f6c
commit 440177c133
2 changed files with 0 additions and 24 deletions

View file

@ -68,12 +68,6 @@ function valueUpdate(value: string) {
v-model="model" v-model="model"
class="col-2" class="col-2"
> >
<template #year="{ value }">
{{ $i18n.locale === 'tha' ? value + 543 : value }}
</template>
<template #year-overlay-value="{ value }">
{{ $i18n.locale === 'tha' ? value + 543 : value }}
</template>
<template #trigger> <template #trigger>
<q-input <q-input
placeholder="DD/MM/YYYY" placeholder="DD/MM/YYYY"

View file

@ -19,21 +19,9 @@ export function dateFormat(
if (!m.isValid()) return ''; if (!m.isValid()) return '';
let yearOffset = 0;
if (moment.locale() === 'th') {
yearOffset = 543;
}
if (time) return m.format('HH:mm'); if (time) return m.format('HH:mm');
if (number) { if (number) {
let formattedNumberDate = m.format('L'); let formattedNumberDate = m.format('L');
if (yearOffset) {
const adjustedYear = m.year() + yearOffset;
formattedNumberDate = formattedNumberDate.replace(
m.year().toString(),
adjustedYear.toString(),
);
}
return formattedNumberDate; return formattedNumberDate;
} }
@ -42,12 +30,6 @@ export function dateFormat(
`DD ${monthFormat} YYYY ${time ? ' HH:mm' : ''}`, `DD ${monthFormat} YYYY ${time ? ' HH:mm' : ''}`,
); );
// Adjust year for Buddhist calendar if locale is 'th'
if (yearOffset) {
const adjustedYear = m.year() + yearOffset;
return formattedDate.replace(m.year().toString(), adjustedYear.toString());
}
return formattedDate; return formattedDate;
} }