fix bug function monthYear2Thai
This commit is contained in:
parent
72ba71c1f6
commit
fa22a301aa
1 changed files with 13 additions and 14 deletions
|
|
@ -189,7 +189,13 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function monthYear2Thai(month: number, year: number, isFullMonth = false) {
|
function monthYear2Thai(month: number, year: number, isFullMonth = false) {
|
||||||
const date = new Date(`${year}-${month + 1}-1`);
|
if (
|
||||||
|
month < 0 ||
|
||||||
|
month > 11 ||
|
||||||
|
!Number.isFinite(month) ||
|
||||||
|
!Number.isFinite(year)
|
||||||
|
)
|
||||||
|
return "";
|
||||||
const fullMonthThai = [
|
const fullMonthThai = [
|
||||||
"มกราคม",
|
"มกราคม",
|
||||||
"กุมภาพันธ์",
|
"กุมภาพันธ์",
|
||||||
|
|
@ -218,19 +224,12 @@ export const useCounterMixin = defineStore("mixin", () => {
|
||||||
"พ.ย.",
|
"พ.ย.",
|
||||||
"ธ.ค.",
|
"ธ.ค.",
|
||||||
];
|
];
|
||||||
let dstYear = 0;
|
|
||||||
if (date.getFullYear() > 2500) {
|
// assume year is in BE if > 2500
|
||||||
dstYear = date.getFullYear();
|
let dstYear = year > 2500 ? year : year + 543;
|
||||||
} else {
|
// month is already 0-based
|
||||||
dstYear = date.getFullYear() + 543;
|
let dstMonth = isFullMonth ? fullMonthThai[month] : abbrMonthThai[month];
|
||||||
}
|
return `${dstMonth} ${dstYear}`;
|
||||||
let dstMonth = "";
|
|
||||||
if (isFullMonth) {
|
|
||||||
dstMonth = fullMonthThai[date.getMonth()];
|
|
||||||
} else {
|
|
||||||
dstMonth = abbrMonthThai[date.getMonth()];
|
|
||||||
}
|
|
||||||
return dstMonth + " " + dstYear;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dateToISO(date: Date) {
|
function dateToISO(date: Date) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue