Total Complexity | 2 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait DateTrait |
||
13 | { |
||
14 | /** |
||
15 | * The ·lexical space· of date consists of finite-length sequences of characters of the form: |
||
16 | * '-'? yyyy '-' mm '-' dd zzzzzz? |
||
17 | * |
||
18 | * where the date and optional timezone are represented exactly the same way as they are for dateTime. |
||
19 | * The first moment of the interval is that represented by: |
||
20 | * '-' yyyy '-' mm '-' dd 'T00:00:00' zzzzzz? |
||
21 | * |
||
22 | * and the least upper bound of the interval is the timeline point represented (noncanonically) by: |
||
23 | * '-' yyyy '-' mm '-' dd 'T24:00:00' zzzzzz?. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private static string $date_regex = '/^ |
||
28 | -? |
||
29 | ([1-9][0-9]*|[0-9]{4}) |
||
30 | - |
||
31 | ( |
||
32 | ((0(1|3|5|7|8)|1(0|2))-(0[1-9]|(1|2)[0-9]|3[0-1])) |
||
33 | |((0(4|6|9)|11)-(0[1-9]|(1|2)[0-9]|30)) |
||
34 | |(02-(0[1-9]|(1|2)[0-9])) |
||
35 | ) |
||
36 | ( |
||
37 | ([+-] |
||
38 | ([0-1][0-9]|2[0-4]) |
||
39 | : |
||
40 | (0[0-9]|[1-5][0-9]) |
||
41 | )|Z |
||
42 | )?$/Dx'; |
||
43 | |||
44 | |||
45 | /** |
||
46 | * @param string $value |
||
47 | * @param string $message |
||
48 | */ |
||
49 | protected static function validDate(string $value, string $message = ''): void |
||
59 |