refactor: use A.D. year
This commit is contained in:
parent
7e9a033a47
commit
f96837b133
2 changed files with 3 additions and 11 deletions
|
|
@ -139,20 +139,12 @@ export function disabledAfterToday(date: Date) {
|
|||
return date > today;
|
||||
}
|
||||
|
||||
export function parseAndFormatDate(
|
||||
value: string | number | undefined,
|
||||
locale: string,
|
||||
) {
|
||||
export function parseAndFormatDate(value: string | number | undefined) {
|
||||
if (!value) return;
|
||||
|
||||
if (value && value.toString().length === 10) {
|
||||
const [date, month, year] = value.toString().split('/');
|
||||
if (locale === 'tha') {
|
||||
const adjustedYear = Number(year) - 543;
|
||||
return new Date(`${adjustedYear}-${month}-${date}T00:00:00.000Z`);
|
||||
} else {
|
||||
return new Date(`${year}-${month}-${date}T00:00:00.000Z`);
|
||||
}
|
||||
return new Date(`${year}-${month}-${date}T00:00:00.000Z`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue