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
|
function getWishlistNameSuggestion(): string
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
$month = date('n');
|
$month = date('n');
|
||||||
$season = '';
|
$name = '';
|
||||||
|
|
||||||
|
$startOfBirthdate = null;
|
||||||
$startOfEaster = strtotime('15. April'); // Approximate
|
$startOfEaster = strtotime('15. April'); // Approximate
|
||||||
$startOfChristmas = strtotime('24. December');
|
$startOfChristmas = strtotime('24. December');
|
||||||
|
|
||||||
if ($now <= $startOfEaster) {
|
if ($user->birthdate) {
|
||||||
$season = 'Easter';
|
$birthdates = explode('-', $user->birthdate);
|
||||||
} elseif ($now <= $startOfChristmas) {
|
|
||||||
$season = 'Christmas';
|
$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