Add birthdate to wishlist name suggestion
This commit is contained in:
parent
89307c571b
commit
7f694cb41a
1 changed files with 22 additions and 8 deletions
|
@ -8,18 +8,32 @@
|
|||
|
||||
function getWishlistNameSuggestion(): string
|
||||
{
|
||||
global $user;
|
||||
|
||||
$now = time();
|
||||
$month = date('n');
|
||||
$season = '';
|
||||
$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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue