diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index c8270771..56424ff6 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -5,17 +5,28 @@ export function calculateAge(start: Date, end = new Date()) { let month = end.getMonth() - start.getMonth(); let day = end.getDate() - start.getDate(); - if (month < 0) { - month += 12; - year -= 1; - } - if (day < 0) { - month -= 1; - day = - new Date(start.getFullYear(), start.getMonth(), 0).getDate() - - start.getDate() + - end.getDate(); - } + // if (month < 0) { + // month += 12; + // year -= 1; + // } + // if (day < 0) { + // month -= 1; + // day = + // new Date(start.getFullYear(), start.getMonth(), 0).getDate() - + // start.getDate() + + // end.getDate(); + // } + + if (day < 0) { + month -= 1; + day += new Date(end.getFullYear(), end.getMonth(), 0).getDate(); + } + + if (month < 0) { + month += 12; + year -= 1; + } + return { year, month, day }; }