refactor(utils): merge 2 statement of same conditions

This commit is contained in:
Methapon2001 2024-03-11 10:49:02 +07:00
parent ae49719734
commit 0e1d5f0bf8

View file

@ -5,8 +5,10 @@ export function calculateAge(start: Date, end = new Date()) {
let month = end.getMonth() - start.getMonth(); let month = end.getMonth() - start.getMonth();
let day = end.getDate() - start.getDate(); let day = end.getDate() - start.getDate();
if (month < 0) year -= 1; if (month < 0) {
if (month < 0) month += 12; month += 12;
year -= 1;
}
if (day < 0) { if (day < 0) {
month -= 1; month -= 1;
day = day =