From 36750995b0c55a9881f6cba9744cf0a566fcd43b Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Mon, 4 Mar 2024 13:37:59 +0100 Subject: [PATCH] Use system timezone --- .../UserRegistrationDateCondition.class.php | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php index 2be3cfd7cd..b10a79ff18 100644 --- a/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php +++ b/wcfsetup/install/files/lib/system/condition/UserRegistrationDateCondition.class.php @@ -51,15 +51,27 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme } if (isset($conditionData['registrationDateEnd'])) { + $registrationDateEnd = \DateTime::createFromFormat( + 'Y-m-d', + $conditionData['registrationDateEnd'], + TIMEZONE + ); + $registrationDateEnd->setTime(23, 59, 59); $objectList->getConditionBuilder()->add( 'user_table.registrationDate < ?', - [\strtotime($conditionData['registrationDateEnd']) + 86400] + [$registrationDateEnd->getTimestamp()] ); } if (isset($conditionData['registrationDateStart'])) { + $registrationDateStart = \DateTime::createFromFormat( + 'Y-m-d', + $conditionData['registrationDateStart'], + TIMEZONE + ); + $registrationDateStart->setTime(0, 0, 0); $objectList->getConditionBuilder()->add( 'user_table.registrationDate >= ?', - [\strtotime($conditionData['registrationDateStart'])] + [$registrationDateStart->getTimestamp()] ); } } @@ -70,15 +82,21 @@ class UserRegistrationDateCondition extends AbstractSingleFieldCondition impleme public function checkUser(Condition $condition, User $user) { /** @noinspection PhpUndefinedFieldInspection */ - $registrationDateStart = $condition->registrationDateStart; - if ($registrationDateStart !== null && $user->registrationDate < \strtotime($registrationDateStart)) { - return false; + $registrationDateStart = \DateTime::createFromFormat('Y-m-d', $condition->registrationDateStart, TIMEZONE); + if ($registrationDateStart !== false) { + $registrationDateStart->setTime(0, 0, 0); + if ($user->registrationDate < $registrationDateStart->getTimestamp()) { + return false; + } } /** @noinspection PhpUndefinedFieldInspection */ - $registrationDateEnd = $condition->registrationDateEnd; - if ($registrationDateEnd !== null && $user->registrationDate >= \strtotime($registrationDateEnd) + 86400) { - return false; + $registrationDateEnd = \DateTime::createFromFormat('Y-m-d', $condition->registrationDateEnd, TIMEZONE); + if ($registrationDateEnd !== false) { + $registrationDateEnd->setTime(23, 59, 59); + if ($user->registrationDate >= $registrationDateEnd->getTimestamp()) { + return false; + } } return true; @@ -166,7 +184,7 @@ HTML; { $registrationDateEnd = $registrationDateStart = null; if (\strlen($this->registrationDateStart)) { - $registrationDateStart = @\strtotime($this->registrationDateStart); + $registrationDateStart = \DateTime::createFromFormat('Y-m-d', $this->registrationDateStart, TIMEZONE); if ($registrationDateStart === false) { $this->errorMessage = 'wcf.condition.timestamp.error.invalidStart'; @@ -174,7 +192,7 @@ HTML; } } if (\strlen($this->registrationDateEnd)) { - $registrationDateEnd = @\strtotime($this->registrationDateEnd); + $registrationDateEnd = \DateTime::createFromFormat('Y-m-d', $this->registrationDateEnd, TIMEZONE); if ($registrationDateEnd === false) { $this->errorMessage = 'wcf.condition.timestamp.error.invalidEnd'; -- 2.20.1