You are here

public function Rss::getDateModified in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php \Zend\Feed\Reader\Entry\Rss::getDateModified()
  2. 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getDateModified()
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php \Zend\Feed\Reader\Entry\Rss::getDateModified()

Get the entry's date of modification

Return value

string

Throws

Exception\RuntimeException

Overrides EntryInterface::getDateModified

1 call to Rss::getDateModified()
Rss::getDateCreated in vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php
Get the entry's date of creation

File

vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php, line 183

Class

Rss

Namespace

Zend\Feed\Reader\Entry

Code

public function getDateModified() {
  if (array_key_exists('datemodified', $this->data)) {
    return $this->data['datemodified'];
  }
  $date = null;
  if ($this
    ->getType() !== Reader\Reader::TYPE_RSS_10 && $this
    ->getType() !== Reader\Reader::TYPE_RSS_090) {
    $dateModified = $this->xpath
      ->evaluate('string(' . $this->xpathQueryRss . '/pubDate)');
    if ($dateModified) {
      $dateModifiedParsed = strtotime($dateModified);
      if ($dateModifiedParsed) {
        $date = new DateTime('@' . $dateModifiedParsed);
      }
      else {
        $dateStandards = [
          DateTime::RSS,
          DateTime::RFC822,
          DateTime::RFC2822,
          null,
        ];
        foreach ($dateStandards as $standard) {
          try {
            $date = date_create_from_format($standard, $dateModified);
            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 = $this
      ->getExtension('DublinCore')
      ->getDate();
  }
  if (!$date) {
    $date = $this
      ->getExtension('Atom')
      ->getDateModified();
  }
  if (!$date) {
    $date = null;
  }
  $this->data['datemodified'] = $date;
  return $this->data['datemodified'];
}