diff --git a/src/functions/getCurrentSeason.php b/src/functions/getCurrentSeason.php index 2aa15bef..89d38b3a 100644 --- a/src/functions/getCurrentSeason.php +++ b/src/functions/getCurrentSeason.php @@ -8,18 +8,32 @@ function getWishlistNameSuggestion(): string { - $now = time(); - $month = date('n'); - $season = ''; + global $user; + $now = time(); + $month = date('n'); + $name = ''; + + $startOfBirthdate = null; $startOfEaster = strtotime('15. April'); // Approximate $startOfChristmas = strtotime('24. December'); - if ($now <= $startOfEaster) { - $season = 'Easter'; - } elseif ($now <= $startOfChristmas) { - $season = 'Christmas'; + if ($user->birthdate) { + $birthdates = explode('-', $user->birthdate); + + $birthdate = new \DateTime(); + $birthdate->setDate(date('Y'), $birthdates[1], $birthdates[2]); + + $startOfBirthdate = $birthdate->getTimestamp(); } - return $season; + if ($startOfBirthdate && $now <= $startOfBirthdate) { + $name = 'Birthday'; + } elseif ($now <= $startOfEaster) { + $name = 'Easter'; + } elseif ($now <= $startOfChristmas) { + $name = 'Christmas'; + } + + return $name; }