1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Core;
4:
5: use DateTimeImmutable;
6: use DateTimeZone;
7:
8: /**
9: * @api
10: */
11: interface DateParserInterface
12: {
13: /**
14: * Convert a value to a date and time, or return null if it can't be parsed
15: *
16: * If the value does not specify a timezone, one of the following is used
17: * during parsing:
18: *
19: * - `$timezone` (if given)
20: * - the parser's default timezone (if applicable)
21: * - the script's default timezone (if set)
22: * - `UTC`
23: *
24: * If `$timezone` is given, it is applied to the date and time before it is
25: * returned.
26: */
27: public function parse(
28: string $value,
29: ?DateTimeZone $timezone = null
30: ): ?DateTimeImmutable;
31: }
32: