Total Complexity | 2 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | trait DateTrait |
||
17 | { |
||
18 | /** |
||
19 | * The format that should be used when determining how to parse a date from a date string. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $createFromFormat; |
||
24 | |||
25 | /** |
||
26 | * The preferred timezone to use for date output. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $outputTimezone; |
||
31 | |||
32 | /** |
||
33 | * Allows the user to help the date parser by providing the format of the datestamp in the feed. |
||
34 | * |
||
35 | * This will be passed into `DateTime::createFromFormat()` at parse-time. |
||
36 | * |
||
37 | * @param string $createFromFormat The format of the datestamp in the feed. |
||
38 | * |
||
39 | * @return self |
||
40 | * |
||
41 | * @see http://php.net/manual/en/datetime.createfromformat.php |
||
42 | */ |
||
43 | public function setDateFormat(string $createFromFormat): self |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Set the preferred output timezone. |
||
52 | * |
||
53 | * This calculation is performed on a _best-effort_ basis and is not guaranteed. Factors which may affect the |
||
54 | * calculation include: |
||
55 | * |
||
56 | * * the version of glibc/musl that your OS relies on |
||
57 | * * the freshness of the timestamp data your OS relies on |
||
58 | * * the format of the datestamp inside of the feed and PHP's ability to parse it |
||
59 | * |
||
60 | * @param string $timezone The timezone identifier to use. Must be compatible with `DateTimeZone`. The default |
||
61 | * value is `UTC`. |
||
62 | * |
||
63 | * @return self |
||
64 | */ |
||
65 | public function setOutputTimezone(string $timezone = 'UTC'): self |
||
72 |