fix: input datepicker th (function)
This commit is contained in:
parent
53669267b1
commit
8e173a996f
1 changed files with 14 additions and 5 deletions
|
|
@ -104,12 +104,21 @@ export function disabledAfterToday(date: Date) {
|
|||
return date > today;
|
||||
}
|
||||
|
||||
export function parseAndFormatDate(value: string | number | undefined) {
|
||||
export function parseAndFormatDate(
|
||||
value: string | number | undefined,
|
||||
locale: string,
|
||||
) {
|
||||
if (!value) return;
|
||||
if (value && value.toString().length === 10) {
|
||||
const [year, month, day] = value.toString().split('/');
|
||||
|
||||
return new Date(`${day}/${month}/${year}`);
|
||||
if (value && value.toString().length === 10) {
|
||||
const [date, month, year] = value.toString().split('/');
|
||||
|
||||
if (locale === 'th-th') {
|
||||
const adjustedYear = Number(year) - 543;
|
||||
return new Date(`${month}/${date}/${adjustedYear}`);
|
||||
} else {
|
||||
return new Date(`${month}/${date}/${year}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue