1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Forced date can now be a timestamp too

Add adding more tests for forced content
This commit is contained in:
Jeremy Benoist 2017-05-24 16:44:03 +02:00
parent 9e349f08a6
commit f0378b4d7c
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
3 changed files with 90 additions and 2 deletions

View file

@ -286,7 +286,7 @@ class EntryRestController extends WallabagRestController
* {"name"="content", "dataType"="string", "required"=false, "description"="Content of the entry"},
* {"name"="language", "dataType"="string", "required"=false, "description"="Language of the entry"},
* {"name"="preview_picture", "dataType"="string", "required"=false, "description"="Preview picture of the entry"},
* {"name"="published_at", "dataType"="datetime", "format"="YYYY-MM-DDTHH:II:SS+TZ", "required"=false, "description"="Published date of the entry"},
* {"name"="published_at", "dataType"="datetime|integer", "format"="YYYY-MM-DDTHH:II:SS+TZ or a timestamp", "required"=false, "description"="Published date of the entry"},
* {"name"="authors", "dataType"="string", "format"="Name Firstname,author2,author3", "required"=false, "description"="Authors of the entry"},
* }
* )

View file

@ -82,8 +82,15 @@ class ContentProxy
$entry->setHttpStatus(isset($content['status']) ? $content['status'] : '');
if (!empty($content['date'])) {
$date = $content['date'];
// is it a timestamp?
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
$date = '@'.$content['date'];
}
try {
$entry->setPublishedAt(new \DateTime($content['date']));
$entry->setPublishedAt(new \DateTime($date));
} catch (\Exception $e) {
$this->logger->warning('Error while defining date', ['e' => $e, 'url' => $url, 'date' => $content['date']]);
}