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
3 changed files with 90 additions and 2 deletions

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']]);
}