Skip to content

Commit

Permalink
Merge pull request #83 from schaeferalex/fix-carbon-timezone-casting
Browse files Browse the repository at this point in the history
Preserve timezone offset for Carbon casts
  • Loading branch information
WendellAdriel authored Jul 22, 2024
2 parents 102c311 + ede9923 commit eceb7b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SimpleDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private function formatArrayableValue(mixed $value): array|int|string
is_array($value) => $value,
$value instanceof BackedEnum => $value->value,
$value instanceof UnitEnum => $value->name,
$value instanceof Carbon || $value instanceof CarbonImmutable => $value->toISOString(),
$value instanceof Carbon || $value instanceof CarbonImmutable => $value->toISOString(true),
$value instanceof Collection => $this->transformCollectionToArray($value),
$value instanceof Model => $this->transformModelToArray($value),
$value instanceof SimpleDTO => $this->transformDTOToArray($value),
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/ValidatedDTOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ public function __invoke() {}
->toBe([
'unitEnum' => 'ONE',
'backedEnum' => 'bar',
'carbon' => '2023-10-16T00:00:00.000000Z',
'carbonImmutable' => '2023-10-15T00:00:00.000000Z',
'carbon' => '2023-10-16T00:00:00.000000+00:00',
'carbonImmutable' => '2023-10-15T00:00:00.000000+00:00',
]);
});

Expand Down

0 comments on commit eceb7b7

Please sign in to comment.