/**
 * Calcul d'âge pour les profils enfants.
 * Format compact : "3 ans" / "3 ans et 2 mois" / "4 mois" / "2 semaines" / "5 jours".
 */
/** Âge exact (années/mois/jours) à une date donnée. */
export function ageParts(birthDate, at) {
    if (at < birthDate)
        return { years: 0, months: 0, days: 0 };
    let years = at.getUTCFullYear() - birthDate.getUTCFullYear();
    let months = at.getUTCMonth() - birthDate.getUTCMonth();
    let days = at.getUTCDate() - birthDate.getUTCDate();
    if (days < 0) {
        months -= 1;
        const prevMonth = new Date(Date.UTC(at.getUTCFullYear(), at.getUTCMonth(), 0));
        days += prevMonth.getUTCDate();
    }
    if (months < 0) {
        years -= 1;
        months += 12;
    }
    return { years, months, days };
}
/** Format compact français. */
export function formatAge(birthDate, at) {
    const { years, months, days } = ageParts(birthDate, at);
    if (years >= 2)
        return `${years} ans`;
    if (years === 1)
        return `${years} an${months > 0 ? ` et ${months} mois` : ""}`;
    if (months > 0)
        return `${months} mois`;
    if (days > 14)
        return `${Math.floor(days / 7)} semaines`;
    if (days > 0)
        return `${days} jour${days > 1 ? "s" : ""}`;
    return "aujourd'hui";
}
//# sourceMappingURL=age.js.map