/** * Find the item date. * * @param SimpleXMLElement $entry Feed item * @param Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $date = XmlParser::getXPathResult($entry, 'pubDate'); $item->date = empty($date) ? $feed->getDate() : $this->date->getDateTime((string) current($date)); }
/** * Find the item date * * @access public * @param SimpleXMLElement $entry Feed item * @param Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $published = XmlParser::getXPathResult($entry, 'atom:published', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'published'); $updated = XmlParser::getXPathResult($entry, 'atom:updated', $this->namespaces) ?: XmlParser::getXPathResult($entry, 'updated'); $published = !empty($published) ? $this->date->getDateTime((string) current($published)) : null; $updated = !empty($updated) ? $this->date->getDateTime((string) current($updated)) : null; if ($published === null && $updated === null) { $item->date = $feed->getDate(); // We use the feed date if there is no date for the item } else { if ($published !== null && $updated !== null) { $item->date = max($published, $updated); // We use the most recent date between published and updated } else { $item->date = $updated ?: $published; } } }
/** * Find the item date * * @access public * @param SimpleXMLElement $entry Feed item * @param Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $date = XmlParser::getNamespaceValue($entry, $this->namespaces, 'date'); if (empty($date)) { $date = XmlParser::getNamespaceValue($entry, $this->namespaces, 'updated'); } if (empty($date)) { $date = (string) $entry->pubDate; } $item->date = empty($date) ? $feed->getDate() : $this->date->getDateTime($date); }
/** * Find the item date * * @access public * @param SimpleXMLElement $entry Feed item * @param Item $item Item object * @param \PicoFeed\Parser\Feed $feed Feed object */ public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed) { $published = isset($entry->published) ? $this->date->getDateTime((string) $entry->published) : null; $updated = isset($entry->updated) ? $this->date->getDateTime((string) $entry->updated) : null; if ($published === null && $updated === null) { $item->date = $feed->getDate(); // We use the feed date if there is no date for the item } else { if ($published !== null && $updated !== null) { $item->date = max($published, $updated); // We use the most recent date between published and updated } else { $item->date = $updated ?: $published; } } }