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 | |
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')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/ContentProxy.php | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index cc2cca64..c3ba1858 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -286,7 +286,7 @@ class EntryRestController extends WallabagRestController | |||
286 | * {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"}, | 286 | * {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"}, |
287 | * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"}, | 287 | * {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"}, |
288 | * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"}, | 288 | * {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"}, |
289 | * {"name"="published_at", "dataType"="datetime", "format"="YYYY-MM-DDTHH:II:SS+TZ", "required"=false, "description"="Published date of the entry"}, | 289 | * {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"}, |
290 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, | 290 | * {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"}, |
291 | * } | 291 | * } |
292 | * ) | 292 | * ) |
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 | } |