diff --git a/CHANGELOG.md b/CHANGELOG.md index d076f63..6db8165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Api/Graph/Fields/FormattableDate.php b/src/Api/Graph/Fields/FormattableDate.php index 96d64e5..f76b96a 100644 --- a/src/Api/Graph/Fields/FormattableDate.php +++ b/src/Api/Graph/Fields/FormattableDate.php @@ -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; }