Correct empty timestamp check in createDateTimeFromTimestamp

createDateTimeFromTimestamp interpreted 0 as timestamp as a mistake while 0 is a valid timestamp.
The fix checks if timestamp is null (not defined/initialized), so that 0 is treated as a correct timestamp.
This commit is contained in:
Jonathan Flueren 2021-08-12 15:27:58 +02:00
parent a87c010c77
commit 9ac7758e87
2 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ class EpisodeActionController extends Controller {
* @return DateTime
*/
private function createDateTimeFromTimestamp(?int $since): DateTime {
return ($since)
return ($since !== null)
? (new \DateTime)->setTimestamp($since)
: (new \DateTime('-1 week'));
}

View File

@ -73,7 +73,7 @@ class SubscriptionChangeController extends Controller {
* @return DateTime
*/
private function createDateTimeFromTimestamp(?int $since): DateTime {
return ($since)
return ($since !== null)
? (new \DateTime)->setTimestamp($since)
: (new \DateTime('-1 week'));
}