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