public function Rss::getLastBuildDate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getLastBuildDate()
Get the feed lastBuild date
Return value
DateTime
Throws
Exception\RuntimeException
File
- vendor/
zendframework/ zend-feed/ src/ Reader/ Feed/ Rss.php, line 252
Class
Namespace
Zend\Feed\Reader\FeedCode
public function getLastBuildDate() {
if (array_key_exists('lastBuildDate', $this->data)) {
return $this->data['lastBuildDate'];
}
$date = null;
if ($this
->getType() !== Reader\Reader::TYPE_RSS_10 && $this
->getType() !== Reader\Reader::TYPE_RSS_090) {
$lastBuildDate = $this->xpath
->evaluate('string(/rss/channel/lastBuildDate)');
if ($lastBuildDate) {
$lastBuildDateParsed = strtotime($lastBuildDate);
if ($lastBuildDateParsed) {
$date = new DateTime('@' . $lastBuildDateParsed);
}
else {
$dateStandards = [
DateTime::RSS,
DateTime::RFC822,
DateTime::RFC2822,
null,
];
foreach ($dateStandards as $standard) {
try {
$date = DateTime::createFromFormat($standard, $lastBuildDateParsed);
break;
} catch (\Exception $e) {
if ($standard === null) {
throw new Exception\RuntimeException('Could not load date due to unrecognised' . ' format (should follow RFC 822 or 2822):' . $e
->getMessage(), 0, $e);
}
}
}
}
}
}
if (!$date) {
$date = null;
}
$this->data['lastBuildDate'] = $date;
return $this->data['lastBuildDate'];
}