PicoFeed\Parser\Parser::findItemDate PHP Method

findItemDate() public method

Find the item date.
public findItemDate ( SimpleXMLElement $entry, PicoFeed\Parser\Item $item, PicoFeed\Parser\Feed $feed )
$entry SimpleXMLElement Feed item
$item PicoFeed\Parser\Item Item object
$feed PicoFeed\Parser\Feed Feed object
    public function findItemDate(SimpleXMLElement $entry, Item $item, Feed $feed)
    {
        $this->findItemPublishedDate($entry, $item, $feed);
        $this->findItemUpdatedDate($entry, $item, $feed);
        if ($item->getPublishedDate() === null) {
            // Use the updated date if available, otherwise use the feed date
            $item->setPublishedDate($item->getUpdatedDate() ?: $feed->getDate());
        }
        if ($item->getUpdatedDate() === null) {
            // Use the published date as fallback
            $item->setUpdatedDate($item->getPublishedDate());
        }
        // Use the most recent of published and updated dates
        $item->setDate(max($item->getPublishedDate(), $item->getUpdatedDate()));
    }