feat(03): young worker warning dialog
This commit is contained in:
parent
6790b5f938
commit
70b50e132f
4 changed files with 64 additions and 5 deletions
|
|
@ -78,9 +78,11 @@ export function toISOStringWithTimezone(date: Date) {
|
|||
);
|
||||
}
|
||||
|
||||
export function calculateAge(birthDate: Date | null | string) {
|
||||
export function calculateAge(
|
||||
birthDate: Date | null | string,
|
||||
only?: 'year' | 'months' | 'days',
|
||||
) {
|
||||
if (!birthDate) return null;
|
||||
const { locale } = useI18n();
|
||||
|
||||
const birthDateTimeStamp = new Date(birthDate).getTime();
|
||||
const now = new Date();
|
||||
|
|
@ -91,6 +93,11 @@ export function calculateAge(birthDate: Date | null | string) {
|
|||
const months = ageDate.getUTCMonth();
|
||||
const days = ageDate.getUTCDate() - 1;
|
||||
|
||||
if (only) {
|
||||
return only === 'year' ? years : only === 'months' ? months : days;
|
||||
}
|
||||
|
||||
const { locale } = useI18n();
|
||||
if (locale.value === 'tha') {
|
||||
return `${years} ปี ${months !== 0 ? months + ' เดือน' : ''} ${days !== 0 ? days + ' วัน' : ''} `;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue