ปรับฟอร์มการลา

This commit is contained in:
Warunee Tamkoo 2023-11-09 16:00:55 +07:00
parent e850f4fd8a
commit ca4c3565bd
7 changed files with 431 additions and 391 deletions

View file

@ -931,6 +931,24 @@ export const useCounterMixin = defineStore("mixin", () => {
}
}
function calculateDurationYmd(startDate: string | null, endDate: string | null) {
if (startDate && endDate) {
const start = new Date(startDate);
const end = new Date(endDate);
const duration = end.getTime() - start.getTime(); // ระยะเวลาในมิลลิวินาที
const days = Math.floor(duration / (1000 * 60 * 60 * 24));
const months = Math.floor(duration / (1000 * 60 * 60 * 24 * 30.44));
const years = Math.floor(duration / (1000 * 60 * 60 * 24 * 30.44 * 12));
// return `${days} วัน, ${months} เดือน, ${years} ปี`;
return `${years} ปี, ${months} เดือน, ${days} วัน`;
}
return "";
}
return {
calAge,
date2Thai,
@ -963,5 +981,6 @@ export const useCounterMixin = defineStore("mixin", () => {
dialogConfirm,
dialogRemove,
arabicNumberToText,
calculateDurationYmd
};
});