]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/ContentProxy.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / ContentProxy.php
index 656ac6eecb93b4430c2bf413787aaf680646a3c9..854acb6ae3c540d433d7863517b597db566d53ac 100644 (file)
@@ -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]);
         }