Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/3951' into develop
Browse files Browse the repository at this point in the history
Close #3951
  • Loading branch information
weierophinney committed Mar 12, 2013
2 parents 35b513b + ed4c2bd commit 53534f2
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 10 deletions.
6 changes: 3 additions & 3 deletions library/Zend/Feed/Reader/Extension/Atom/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

namespace Zend\Feed\Reader\Extension\Atom;

use DateTime;
use DOMDocument;
use DOMElement;
use stdClass;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Stdlib\DateTime;
use Zend\Uri;

class Entry extends Extension\AbstractEntry
Expand Down Expand Up @@ -170,7 +170,7 @@ public function getDateCreated()
}

if ($dateCreated) {
$date = DateTime::createFromISO8601($dateCreated);
$date = new DateTime($dateCreated);
}

$this->data['datecreated'] = $date;
Expand Down Expand Up @@ -198,7 +198,7 @@ public function getDateModified()
}

if ($dateModified) {
$date = DateTime::createFromISO8601($dateModified);
$date = new DateTime($dateModified);
}

$this->data['datemodified'] = $date;
Expand Down
6 changes: 3 additions & 3 deletions library/Zend/Feed/Reader/Extension/Atom/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace Zend\Feed\Reader\Extension\Atom;

use DateTime;
use DOMElement;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Stdlib\DateTime;
use Zend\Uri;

class Feed extends Extension\AbstractFeed
Expand Down Expand Up @@ -120,7 +120,7 @@ public function getDateCreated()
}

if ($dateCreated) {
$date = DateTime::createFromISO8601($dateCreated);
$date = new DateTime($dateCreated);
}

$this->data['datecreated'] = $date;
Expand Down Expand Up @@ -148,7 +148,7 @@ public function getDateModified()
}

if ($dateModified) {
$date = DateTime::createFromISO8601($dateModified);
$date = new DateTime($dateModified);
}

$this->data['datemodified'] = $date;
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Feed/Reader/Extension/DublinCore/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace Zend\Feed\Reader\Extension\DublinCore;

use DateTime;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Stdlib\DateTime;

class Entry extends Extension\AbstractEntry
{
Expand Down Expand Up @@ -217,7 +217,7 @@ public function getDate()
}

if ($date) {
$d = DateTime::createFromISO8601($date);
$d = new DateTime($date);
}

$this->data['date'] = $d;
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Feed/Reader/Extension/DublinCore/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace Zend\Feed\Reader\Extension\DublinCore;

use DateTime;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Stdlib\DateTime;

class Feed extends Extension\AbstractFeed
{
Expand Down Expand Up @@ -226,7 +226,7 @@ public function getDate()
}

if ($date) {
$d = DateTime::createFromISO8601($date);
$d = new DateTime($date);
}

$this->data['date'] = $d;
Expand Down
4 changes: 4 additions & 0 deletions library/Zend/Stdlib/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

use DateTimeZone;

trigger_error('DateTime extension deprecated as of ZF 2.1.4; use the \DateTime constructor to parse extended ISO8601 dates instead', E_USER_DEPRECATED);

/**
* DateTime
*
* An extension of the \DateTime object.
*
* @deprecated
*/
class DateTime extends \DateTime
{
Expand Down
20 changes: 20 additions & 0 deletions tests/ZendTest/Feed/Reader/Entry/AtomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ public function testGetsDateCreatedFromAtom10()
$this->assertEquals($edate, $entry->getDateCreated());
}

public function testGetsDateCreatedWithFractional()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath . '/datecreated/plain/fractional.xml')
);
$entry = $feed->current();
$edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z');
$this->assertEquals($edate, $entry->getDateCreated());
}

/**
* Get modification date (Unencoded Text)
*/
Expand All @@ -132,6 +142,16 @@ public function testGetsDateModifiedFromAtom10()
$this->assertEquals($edate, $entry->getDateModified());
}

public function testGetsDateModifiedWithFractional()
{
$feed = Reader\Reader::importString(
file_get_contents($this->feedSamplePath . '/datemodified/plain/fractional.xml')
);
$entry = $feed->current();
$edate = DateTime::createFromFormat(DateTime::ISO8601, '2009-03-07T08:03:50Z');
$this->assertEquals($edate, $entry->getDateModified());
}

/**
* Get Title (Unencoded Text)
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<entry>
<created>2009-03-07T08:03:50.80Z</created>
</entry>
</feed>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<entry>
<modified>2009-03-07T08:03:50.80Z</modified>
</entry>
</feed>
10 changes: 10 additions & 0 deletions tests/ZendTest/Stdlib/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase
{
public $dateTime;

public function setUp()
{
set_error_handler(function ($errno, $errstr) {
if (!stristr($errstr, 'datetime extension deprecated')) {
return false;
}
return true;
}, E_USER_DEPRECATED);
}

public function testCreatesIS08601WithoutFractionalSeconds()
{
$time = '2009-03-07T08:03:50Z';
Expand Down

0 comments on commit 53534f2

Please sign in to comment.