diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-05-24 16:44:03 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-05-31 14:00:15 +0200 |
commit | f0378b4d7c7b8c971239445f3a2a1535abab7d00 (patch) | |
tree | 2f8157ce6b50e454887827825ef8ebbc01dfdf70 /src/Wallabag/CoreBundle/Helper/ContentProxy.php | |
parent | 9e349f08a651c43c6d5dd890303ed529c38c4fde (diff) | |
download | wallabag-f0378b4d7c7b8c971239445f3a2a1535abab7d00.tar.gz wallabag-f0378b4d7c7b8c971239445f3a2a1535abab7d00.tar.zst wallabag-f0378b4d7c7b8c971239445f3a2a1535abab7d00.zip |
Forced date can now be a timestamp too
Add adding more tests for forced content
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/ContentProxy.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/ContentProxy.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 90d0c50d..8ba77ca9 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -82,8 +82,15 @@ class ContentProxy | |||
82 | $entry->setHttpStatus(isset($content['status']) ? $content['status'] : ''); | 82 | $entry->setHttpStatus(isset($content['status']) ? $content['status'] : ''); |
83 | 83 | ||
84 | if (!empty($content['date'])) { | 84 | if (!empty($content['date'])) { |
85 | $date = $content['date']; | ||
86 | |||
87 | // is it a timestamp? | ||
88 | if (filter_var($date, FILTER_VALIDATE_INT) !== false) { | ||
89 | $date = '@'.$content['date']; | ||
90 | } | ||
91 | |||
85 | try { | 92 | try { |
86 | $entry->setPublishedAt(new \DateTime($content['date'])); | 93 | $entry->setPublishedAt(new \DateTime($date)); |
87 | } catch (\Exception $e) { | 94 | } catch (\Exception $e) { |
88 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $url, 'date' => $content['date']]); | 95 | $this->logger->warning('Error while defining date', ['e' => $e, 'url' => $url, 'date' => $content['date']]); |
89 | } | 96 | } |