Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 429b18e

Browse filesBrowse files
minor #34895 [Validator][ConstraintValidator] Stop passing unnecessary timezone argument to \DateTime (fancyweb)
This PR was merged into the 3.4 branch. Discussion ---------- [Validator][ConstraintValidator] Stop passing unnecessary timezone argument to \DateTime | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Since we format the \DateTimeImmutable with the "e" character, it uses this timezone identifier and do not consider the passed one. See https://www.php.net/manual/en/datetime.construct.php: > The $timezone parameter and the current timezone are ignored when the $time parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00). Commits ------- 03dbcf8 [Validator][ConstraintValidator] Stop passing unnecessary timezone argument to \DateTime
2 parents 56bfbd8 + 03dbcf8 commit 429b18e
Copy full SHA for 429b18e

File tree

Expand file treeCollapse file tree

2 files changed

+2
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-8
lines changed

‎src/Symfony/Component/Validator/ConstraintValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/ConstraintValidator.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ protected function formatValue($value, $format = 0)
9393
// neither the native nor the stub IntlDateFormatter support
9494
// DateTimeImmutable as of yet
9595
if (!$value instanceof \DateTime) {
96-
$value = new \DateTime(
97-
$value->format('Y-m-d H:i:s.u e'),
98-
$value->getTimezone()
99-
);
96+
$value = new \DateTime($value->format('Y-m-d H:i:s.u e'));
10097
}
10198

10299
return $formatter->format($value);

‎src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ protected static function addPhp5Dot5Comparisons(array $comparisons)
5353

5454
foreach ($comparison as $i => $value) {
5555
if ($value instanceof \DateTime) {
56-
$comparison[$i] = new \DateTimeImmutable(
57-
$value->format('Y-m-d H:i:s.u e'),
58-
$value->getTimezone()
59-
);
56+
$comparison[$i] = new \DateTimeImmutable($value->format('Y-m-d H:i:s.u e'));
6057
$add = true;
6158
} elseif ('DateTime' === $value) {
6259
$comparison[$i] = 'DateTimeImmutable';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.