Construct a birthday year if none provided and hide its display

This commit is contained in:
Janosch Maier 2021-04-05 13:11:02 +02:00 committed by Ben Gotow
parent 0540b6571b
commit 27ae37620f

View file

@ -149,7 +149,11 @@ const ContactAttributes = ({
<Icons.Crown />
</label>
<div>
{new Date(item.date.year, item.date.month - 1, item.date.day).toLocaleDateString()}
{ // If there is no year given, solely display the month and day
item.date.year ?
new Date(item.date.year, item.date.month - 1, item.date.day).toLocaleDateString() :
new Date(new Date().getFullYear(), item.date.month - 1, item.date.day).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })
}
</div>
</div>
))}