Skip to content

Commit

Permalink
feature #47730 Ban DateTime from the codebase (WebMamba)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 6.2 branch.

Discussion
----------

Ban DateTime from the codebase

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | #47580
| License       | MIT
| Doc PR        | symfony

As discuss in this issue, the purpose of this PR is to remove DateTime from the code base in favor to DateTimeImmutable. I will process it component by component. Feel free to discuss!

Commits
-------

689385a83f Ban DateTime from the codebase
  • Loading branch information
fabpot committed Oct 9, 2022
2 parents f26df6e + 9e671ae commit 6d0b296
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -796,17 +796,17 @@ public function testIsImmutable()
public function testSetDate()
{
$response = new Response();
$response->setDate(\DateTime::createFromFormat(\DateTime::ATOM, '2013-01-26T09:21:56+0100', new \DateTimeZone('Europe/Berlin')));
$response->setDate(\DateTime::createFromFormat(\DateTimeInterface::ATOM, '2013-01-26T09:21:56+0100', new \DateTimeZone('Europe/Berlin')));

$this->assertEquals('2013-01-26T08:21:56+00:00', $response->getDate()->format(\DateTime::ATOM));
$this->assertEquals('2013-01-26T08:21:56+00:00', $response->getDate()->format(\DateTimeInterface::ATOM));
}

public function testSetDateWithImmutable()
{
$response = new Response();
$response->setDate(\DateTimeImmutable::createFromFormat(\DateTime::ATOM, '2013-01-26T09:21:56+0100', new \DateTimeZone('Europe/Berlin')));
$response->setDate(\DateTimeImmutable::createFromFormat(\DateTimeInterface::ATOM, '2013-01-26T09:21:56+0100', new \DateTimeZone('Europe/Berlin')));

$this->assertEquals('2013-01-26T08:21:56+00:00', $response->getDate()->format(\DateTime::ATOM));
$this->assertEquals('2013-01-26T08:21:56+00:00', $response->getDate()->format(\DateTimeInterface::ATOM));
}

public function testSetExpires()
Expand Down

0 comments on commit 6d0b296

Please sign in to comment.