fix: change calculate age function store

This commit is contained in:
puriphatt 2024-07-16 03:24:13 +00:00
parent 204a854a1c
commit 1c5acba093
4 changed files with 6 additions and 46 deletions

View file

@ -44,26 +44,6 @@ export function dialogWarningClose(
});
}
export function calculateAge(birthDate: Date | null | string) {
const { locale } = useI18n();
if (!birthDate) return null;
const birthDateTimeStamp = new Date(birthDate).getTime();
const now = new Date();
const diff = now.getTime() - birthDateTimeStamp;
const ageDate = new Date(diff);
const years = ageDate.getUTCFullYear() - 1970;
const months = ageDate.getUTCMonth();
const days = ageDate.getUTCDate() - 1;
if (locale.value === 'th-th') {
return `${years} ปี ${months !== 0 ? months + ' เดือน' : ''} ${days !== 0 ? days + ' วัน' : ''} `;
} else {
return `${years} years ${months !== 0 ? months + ' months' : ''} ${days !== 0 ? days + ' days' : ''} `;
}
}
export function moveItemUp(items: unknown[], index: number) {
if (index > 0) {
const temp = items[index];