Add birthdate to wishlist name suggestion

This commit is contained in:
Jay Trees 2022-03-23 15:11:13 +01:00
parent 89307c571b
commit 7f694cb41a

View file

@ -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;
}