คัดเลือก เลือกวุฒิการศึกษา
This commit is contained in:
parent
90a47d43ad
commit
b4f20e407b
4 changed files with 79 additions and 3 deletions
|
|
@ -198,6 +198,48 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
return date.getDate().toString().padStart(2, "0") + " " + dstMonth;
|
||||
}
|
||||
|
||||
const calAgeYear = (srcDate: Date, birthCal: Date = new Date()) => {
|
||||
const toDay = birthCal;
|
||||
const birth = new Date(srcDate);
|
||||
|
||||
const yearNow = toDay.getFullYear();
|
||||
const monthNow = toDay.getMonth();
|
||||
const dateNow = toDay.getDate();
|
||||
|
||||
const yearDob = birth.getFullYear();
|
||||
const monthDob = birth.getMonth();
|
||||
const dateDob = birth.getDate();
|
||||
|
||||
const lastYear = 12;
|
||||
const subtractDate: Object = moment().subtract(1, "months").endOf("month");
|
||||
|
||||
const lastMonths = new Date(subtractDate.toString()).getDate();
|
||||
|
||||
let yearAge = yearNow - yearDob;
|
||||
let monthAge = 0;
|
||||
let dateAge = 0;
|
||||
|
||||
if (monthNow >= monthDob) {
|
||||
monthAge = monthNow - monthDob;
|
||||
} else {
|
||||
yearAge--;
|
||||
monthAge = lastYear + monthNow - monthDob;
|
||||
}
|
||||
|
||||
if (dateNow >= dateDob) {
|
||||
dateAge = dateNow - dateDob;
|
||||
} else {
|
||||
monthAge--;
|
||||
dateAge = lastMonths + dateNow - dateDob;
|
||||
|
||||
if (monthAge < 0) {
|
||||
monthAge = 11;
|
||||
yearAge--;
|
||||
}
|
||||
}
|
||||
return yearAge;
|
||||
};
|
||||
|
||||
function monthYear2Thai(month: number, year: number, isFullMonth = false) {
|
||||
const date = new Date(`${year}-${month + 1}-1`);
|
||||
const fullMonthThai = [
|
||||
|
|
@ -809,6 +851,7 @@ export const useCounterMixin = defineStore("mixin", () => {
|
|||
dateToISO,
|
||||
notify,
|
||||
notifyError,
|
||||
calAgeYear,
|
||||
dateText,
|
||||
monthYear2Thai,
|
||||
dateMonth2Thai,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue