X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FContentProxy.php;h=854acb6ae3c540d433d7863517b597db566d53ac;hb=9dd67fa3420c6cfaf7bdae182ca3433c7f636187;hp=656ac6eecb93b4430c2bf413787aaf680646a3c9;hpb=c18a2476b601bc6b9893462d9be680c2e13c89e8;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 656ac6ee..854acb6a 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -125,12 +125,18 @@ class ContentProxy $date = $value; // is it a timestamp? - if (filter_var($date, FILTER_VALIDATE_INT) !== false) { - $date = '@' . $value; + if (false !== filter_var($date, FILTER_VALIDATE_INT)) { + $date = '@' . $date; } try { - $entry->setPublishedAt(new \DateTime($date)); + // is it already a DateTime? + // (it's inside the try/catch in case of fail to be parse time string) + if (!$date instanceof \DateTime) { + $date = new \DateTime($date); + } + + $entry->setPublishedAt($date); } catch (\Exception $e) { $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $entry->getUrl(), 'date' => $value]); }