Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix(DateDecorator): fix date overflow for date decorator on serializa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Jens Schulze committed Mar 15, 2016
1 parent 9781f44 commit 9009b8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Model/Common/DateDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class DateDecorator extends DateTimeDecorator
{
public function jsonSerialize()
{
return $this->getUtcDateTime()->format('Y-m-d');
return $this->getDateTime()->format('Y-m-d');
}
}
11 changes: 11 additions & 0 deletions tests/unit/Model/Common/DateDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@ public function testJsonSerialize()
$decorator->setDateTime(new \DateTime('2015-01-01 12:00', $timezone));
$this->assertSame('2015-01-01', $decorator->jsonSerialize());
}

public function testDateOverflow()
{
$timezone = new \DateTimeZone('CET');
$expected = $time = new \DateTime('2015-01-01', $timezone);
$decorator = new DateDecorator($time);

$date = $decorator->jsonSerialize();
$test = new DateDecorator(new \DateTime($date, $timezone));
$this->assertEquals($expected, $test->getDateTime());
}
}

0 comments on commit 9009b8f

Please # to comment.