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

@ -19,21 +19,9 @@ export function dateFormat(
if (!m.isValid()) return '';
let yearOffset = 0;
if (moment.locale() === 'th') {
yearOffset = 543;
}
if (time) return m.format('HH:mm');
if (number) {
let formattedNumberDate = m.format('L');
if (yearOffset) {
const adjustedYear = m.year() + yearOffset;
formattedNumberDate = formattedNumberDate.replace(
m.year().toString(),
adjustedYear.toString(),
);
}
return formattedNumberDate;
}
@ -42,12 +30,6 @@ export function dateFormat(
`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;
}