feat(web): display age in months when age is 0 (#5961)

* display age in months when age is 0

* simplifying conditionals, using full word "month" over abbreviation
This commit is contained in:
jpsak09 2023-12-25 10:38:14 -06:00 committed by GitHub
parent dea1063b17
commit a7889e5e11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -265,6 +265,9 @@
{#if person.birthDate}
{@const personBirthDate = DateTime.fromISO(person.birthDate)}
{@const age = Math.floor(DateTime.fromISO(asset.fileCreatedAt).diff(personBirthDate, 'years').years)}
{@const ageInMonths = Math.floor(
DateTime.fromISO(asset.fileCreatedAt).diff(personBirthDate, 'months').months,
)}
{#if age >= 0}
<p
class="font-light"
@ -277,7 +280,11 @@
{ locale: $locale },
)}
>
Age {age}
{#if ageInMonths <= 11}
Age {ageInMonths} months
{:else}
Age {age}
{/if}
</p>
{/if}
{/if}