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 string to a date and time, returning null if it can't be parsed
15: *
16: * The timezone used during parsing is the first that applies of:
17: *
18: * - the timezone specified by `$value`
19: * - `$timezone`
20: * - the parser's default timezone (if implemented)
21: * - the default timezone used by date and time functions (if set)
22: * - `UTC`
23: */
24: public function parse(string $value, ?DateTimeZone $timezone = null): ?DateTimeImmutable;
25: }
26: