1
<?php
2

3
namespace Nuwave\Lighthouse\Schema\Types\Scalars;
4

5
use Illuminate\Support\Carbon;
6

7
class DateTimeTz extends DateScalar
8
{
9 1
    protected function format(Carbon $carbon): string
10
    {
11 1
        return $carbon->toIso8601String();
12
    }
13

14 1
    protected function parse($value): Carbon
15
    {
16
        // @phpstan-ignore-next-line We know the format to be good, so this can never return `false`
17 1
        return Carbon::createFromFormat(
18
            // https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601
19
            Carbon::ATOM,
20 1
            $value
21
        );
22
    }
23
}

Read our documentation on viewing source code .

Loading