Example #1
0
 /**
  * Find the feed date.
  *
  * @param SimpleXMLElement      $xml  Feed xml
  * @param \PicoFeed\Parser\Feed $feed Feed object
  */
 public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
 {
     $publish_date = XmlParser::getXPathResult($xml, 'channel/pubDate');
     $update_date = XmlParser::getXPathResult($xml, 'channel/lastBuildDate');
     $published = !empty($publish_date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($publish_date)) : null;
     $updated = !empty($update_date) ? $this->getDateParser()->getDateTime(XmlParser::getValue($update_date)) : null;
     if ($published === null && $updated === null) {
         $feed->setDate($this->getDateParser()->getCurrentDateTime());
         // We use the current date if there is no date for the feed
     } elseif ($published !== null && $updated !== null) {
         $feed->setDate(max($published, $updated));
         // We use the most recent date between published and updated
     } else {
         $feed->setDate($updated ?: $published);
     }
 }
Example #2
0
 /**
  * Find the feed date.
  *
  * @param SimpleXMLElement      $xml  Feed xml
  * @param \PicoFeed\Parser\Feed $feed Feed object
  */
 public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
 {
     $date = XmlParser::getXPathResult($xml, 'rss:channel/dc:date', $this->namespaces) ?: XmlParser::getXPathResult($xml, 'channel/dc:date', $this->namespaces);
     $feed->setDate($this->getDateParser()->getDateTime(XmlParser::getValue($date)));
 }
Example #3
0
 /**
  * Find the feed date.
  *
  * @param SimpleXMLElement      $xml  Feed xml
  * @param \PicoFeed\Parser\Feed $feed Feed object
  */
 public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
 {
     $updated = XmlParser::getXPathResult($xml, 'atom:updated', $this->namespaces) ?: XmlParser::getXPathResult($xml, 'updated');
     $feed->setDate($this->getDateParser()->getDateTime(XmlParser::getValue($updated)));
 }