Skip to content

Commit

Permalink
Update graphql formattable date field to handle integer dates
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannielsen committed Aug 5, 2024
1 parent bdecfcb commit 70a57bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Bug where integer dates were not handled properly when used as a GraphQL FormattableDate

## [1.3.2] - 2024-07-03

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions src/Api/Graph/Fields/FormattableDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ protected function resolve($root, array $args): ?string
{
$date = $root->{$this->getProperty()};

if (is_int($date) && $date !== 0) {
$date = \Carbon\Carbon::createFromTimestamp($date);
}

if (! $date instanceof \Carbon\Carbon) {
return null;
}
Expand Down

0 comments on commit 70a57bf

Please sign in to comment.