/** * Get the feed lastBuild date * * @return Date\Date */ public function getLastBuildDate() { if (array_key_exists('lastBuildDate', $this->_data)) { return $this->_data['lastBuildDate']; } $lastBuildDate = null; $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 Date\Date($lastBuildDateParsed); } else { $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES); $date = new Date\Date(); foreach ($dateStandards as $standard) { try { $date->set($lastBuildDate, $standard); break; } catch (Date\Exception $e) { if ($standard == Date\Date::DATES) { throw new Exception('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']; }
/** * Get update base * * @return Date\Date|null */ public function getUpdateBase() { $updateBase = $this->_getData('updateBase'); $date = null; if ($updateBase) { $date = new Date\Date(); $date->set($updateBase, Date\Date::W3C); } return $date; }
/** * Decorator to format return value of list methods * * @param array $result * @return string */ public static function listDecorator($result) { $ret = ''; $date = new Date(); if (count($result) > 0) { foreach ($result as $record) { $date->set($record['createTime']); $createTimeFormatted = $date->get(Date::RFC_1123); $date->set($record['modifyTime']); $modifyTimeFormatted = $date->get(Date::RFC_1123); $ret .= sprintf(' Filename : %s%s', $record['filename'], PHP_EOL); $ret .= sprintf(' File Size : %d b%s', $record['fileSize'], PHP_EOL); $ret .= sprintf(' Creation Time : %d (%s)%s', $record['createTime'], $createTimeFormatted, PHP_EOL); $ret .= sprintf('Last Modified Time : %d (%s)%s', $record['modifyTime'], $modifyTimeFormatted, PHP_EOL); $ret .= PHP_EOL; } } unset($date); return $ret; }
/** * * * @return Date\Date|null */ public function getDate() { if (array_key_exists('date', $this->_data)) { return $this->_data['date']; } $d = null; $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)'); if (!$date) { $date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)'); } if ($date) { $d = new Date\Date(); $d->set($date, Date\Date::ISO_8601); } $this->_data['date'] = $d; return $this->_data['date']; }
/** * Get the entry modification date * * @return string */ public function getDateModified() { if (array_key_exists('datemodified', $this->_data)) { return $this->_data['datemodified']; } $date = null; if ($this->_getAtomType() === Reader\Reader::TYPE_ATOM_03) { $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)'); } else { $dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)'); } if ($dateModified) { $date = new Date\Date(); $date->set($dateModified, Date\Date::ISO_8601); } $this->_data['datemodified'] = $date; return $this->_data['datemodified']; }
public function testZendDateSerializedToAmf0Date() { $date = new Date\Date('October 23, 1978', null, 'en_US'); $date->set('4:20:00', Date\Date::TIMES); $newBody = new Value\MessageBody('/1/onResult', null, $date); $this->_response->setObjectEncoding(0x0); $this->_response->addAmfBody($newBody); $this->_response->finalize(); $testResponse = $this->_response->getResponse(); // Load the expected response. $mockResponse = file_get_contents(__DIR__ . '/TestAsset/Response/dateAmf0Response.bin'); // Check that the response matches the expected serialized value $this->assertEquals($mockResponse, $testResponse); }
/** * Get modification date (Unencoded Text) * @group ZFR002 */ public function testGetsDateModifiedFromAtom10() { $entry = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/atom10.xml')); $edate = new Date\Date(); $edate->set('2009-03-07T08:03:50Z', Date\Date::ISO_8601); $this->assertTrue($edate->equals($entry->getDateModified())); }
/** * Get the entry's date of modification * * @return string */ public function getDateModified() { if (array_key_exists('datemodified', $this->_data)) { return $this->_data['datemodified']; } $dateModified = null; $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 Date\Date($dateModifiedParsed); } else { $dateStandards = array(Date\Date::RSS, Date\Date::RFC_822, Date\Date::RFC_2822, Date\Date::DATES); $date = new Date\Date(); foreach ($dateStandards as $standard) { try { $date->set($dateModified, $standard); break; } catch (Date\Exception $e) { if ($standard == Date\Date::DATES) { require_once 'Zend/Feed/Exception.php'; throw new Exception('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']; }
/** * @issue ZF-7908 */ public function testGetsDateModifiedFromRss20_UnrecognisedGmtFormat() { $feed = Reader\Reader::importString(file_get_contents($this->_feedSamplePath . '/datemodified/plain/rss20-zf-7908.xml')); $entry = $feed->current(); //$this->assertEquals('Sunday 11 January 2009 09 55 59 +0000', $entry->getDateModified()->toString('EEEE dd MMMM YYYY HH mm ss ZZZ')); $edate = new Date\Date(); $edate->set('Sun, 11 Jan 2009 09:55:59 GMT', Date\Date::RSS); $this->assertTrue($edate->equals($entry->getDateModified())); }
/** * @ZF-9891 */ public function testComparingDatesWithoutOption() { $date = new Date(strtotime('Sat, 07 Mar 2009 08:03:50 +0000')); $date2 = new Date(); $date2->set('Sat, 07 Mar 2009 08:03:50 +0000', Date::RFC_2822); $this->assertTrue($date2->equals($date)); }
/** * Test create bucket * * @return void */ public function testCreateBuckets() { //Valid bucket name $bucket = 'iamavalidbucket'; $location = ''; $requestDate = new Date(); $requestDate->set('Tue, 15 May 2012 15:18:31 +0000', Date::RFC_1123); $this->amazon->setRequestDate($requestDate); $this->amazon->setKeys('AKIAIDCZ2WXN6NNB7YZA', 'sagA0Lge8R+ifORcyb6Z/qVbmtimFCUczvh51Jq8'); //Fake keys /** * Check of request inside _makeRequest * */ $this->uriHttp->expects($this->once())->method('getHost')->with()->will($this->returnValue('s3.amazonaws.com')); $this->uriHttp->expects($this->once())->method('setHost')->with('iamavalidbucket.s3.amazonaws.com'); $this->uriHttp->expects($this->once())->method('setPath')->with('/'); $this->httpClient->expects($this->once())->method('setUri')->with($this->uriHttp); $this->httpClient->expects($this->once())->method('setMethod')->with('PUT'); $this->httpClient->expects($this->once())->method('setHeaders')->with(array("Date" => "Tue, 15 May 2012 15:18:31 +0000", "Content-Type" => "application/xml", "Authorization" => "AWS AKIAIDCZ2WXN6NNB7YZA:Y+T4nZxI1wBi1Yn1BMnOK9CDiOM=")); /** * Fake response inside _makeRequest * */ // Http Response results $this->httpResponse->expects($this->any())->method('getStatusCode')->will($this->returnValue(200)); // Expects to be called only once the method send() then return a Http Response. $this->httpClient->expects($this->once())->method('send')->will($this->returnValue($this->httpResponse)); $response = $this->amazon->createBucket($bucket, $location); $this->assertTrue($response); }
/** * @ZF-8650 */ public function testFractionalPrecision() { $date = new Date(); $date->set('012345', Date::MILLISECOND); $this->assertEquals(3, $date->getFractionalPrecision()); $this->assertEquals('345', $date->toString('S')); $date->setFractionalPrecision(6); $this->assertEquals(6, $date->getFractionalPrecision()); $this->assertEquals('345000', $date->toString('S')); $date->add(200, Date::MILLISECOND); $this->assertEquals(6, $date->getFractionalPrecision()); $this->assertEquals('345200', $date->toString('S')); }