refactor: FeedItem::setTimestamp() (#3711)

This commit is contained in:
Dag 2023-09-26 00:27:45 +02:00 committed by GitHub
parent f421c45b21
commit ae53adefad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 15 deletions

View file

@ -147,14 +147,16 @@ class FeedItem
return $this->timestamp;
}
public function setTimestamp($timestamp)
public function setTimestamp($datetime)
{
$this->timestamp = null;
if (
!is_numeric($timestamp)
&& !$timestamp = strtotime($timestamp)
) {
Debug::log('Unable to parse timestamp!');
if (is_numeric($datetime)) {
$timestamp = $datetime;
} else {
$timestamp = strtotime($datetime);
if ($timestamp === false) {
Debug::log('Unable to parse timestamp!');
}
}
if ($timestamp <= 0) {
Debug::log('Timestamp must be greater than zero!');