1 | <?php |
||
15 | class DateTime extends \DateTime |
||
16 | { |
||
17 | const ISO_8601_NO_TIMEZONE = 'Y-m-d H:i:s'; |
||
18 | const ISO_8601_DATE_ONLY = 'Y-m-d'; |
||
19 | |||
20 | const FORMAT_LONG = 'd F Y'; |
||
21 | const FORMAT_LONG_DAY_OF_WEEK = 'l, d F Y'; |
||
22 | const FORMAT_SHORT = 'd M Y'; |
||
23 | const FORMAT_SHORT_DAY_OF_WEEK = 'D, d M Y'; |
||
24 | const FORMAT_TIME = 'H:i'; |
||
25 | |||
26 | const TYPE_DATETIME = 'datetime'; |
||
27 | const TYPE_DATE = 'date'; |
||
28 | |||
29 | protected $dateType; |
||
30 | |||
31 | /** @var DateTimeFormatter */ |
||
32 | private $formatter; |
||
33 | |||
34 | /** |
||
35 | * @param string $time |
||
36 | * @param \DateTimeZone $timezone |
||
37 | * @param string $dateType |
||
38 | */ |
||
39 | 45 | public function __construct(string $time = 'now', \DateTimeZone $timezone = null, string $dateType = self::TYPE_DATETIME) |
|
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | 37 | public function getDateType() : string |
|
54 | |||
55 | /** |
||
56 | * @param $dateType |
||
57 | * @return DateTime |
||
58 | */ |
||
59 | 45 | public function setDateType($dateType) : DateTime |
|
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | 24 | public function getShort() : string |
|
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | 35 | public function getLong() : string |
|
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | 5 | public function getUnixTimestamp() : string |
|
97 | |||
98 | /** |
||
99 | * @return DateTime |
||
100 | */ |
||
101 | 2 | public function getGmtDateTime() : DateTime |
|
108 | |||
109 | /** |
||
110 | * @param DateTime $dateTime |
||
111 | * @return bool |
||
112 | */ |
||
113 | 4 | public function isEqualTo(DateTime $dateTime) : bool |
|
117 | |||
118 | /** |
||
119 | * @param DateTime $date |
||
120 | * @return bool |
||
121 | */ |
||
122 | 4 | public function isBefore(DateTime $date) : bool |
|
126 | |||
127 | /** |
||
128 | * @return bool |
||
129 | */ |
||
130 | 2 | public function isToday() : bool |
|
136 | |||
137 | /** |
||
138 | * @param DateTime $date |
||
139 | * @return bool |
||
140 | */ |
||
141 | 4 | public function isAfter(DateTime $date) : bool |
|
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | 6 | public function __toString() : string |
|
153 | } |
||
154 |