Skip to content

Commit

Permalink
Fix wrong date cast.
Browse files Browse the repository at this point in the history
Should *really* get some test coverage....
  • Loading branch information
timostamm committed Oct 19, 2018
1 parent 32cba60 commit c9258a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Normalize timezones in a Doctrine database.",
"type": "library",
"require": {
"php": "^7.1",
"doctrine/dbal": "^2.7"
},
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/TzConversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function castToDB(\DateTimeInterface $dateTime): \DateTimeInterfac
}
$cast = new \DateTime('now', $tz_db);

$cast->setDate($dateTime->format('j'), $dateTime->format('j'), $dateTime->format('j'));
$cast->setDate($dateTime->format('Y'), $dateTime->format('n'), $dateTime->format('j'));

$cast->setTimestamp($dateTime->getTimestamp());
return $dateTime instanceof \DateTimeImmutable ? \DateTimeImmutable::createFromMutable($cast) : $cast;
Expand Down

0 comments on commit c9258a2

Please sign in to comment.