1 | <?php |
||
10 | class DateTime implements IType |
||
11 | { |
||
12 | protected static $comboRegex = |
||
13 | "/^datetime\'(\d{4})-(\d{2})-(\d{2})((\s|T)([0-1][0-9]|2[0-4]):([0-5][0-9])(:([0-5][0-9])([Z]|[\+|-]\d{2}:\d{2})?)?)?\'$/"; |
||
14 | |||
15 | /** |
||
16 | * Gets the type code |
||
17 | * Note: implementation of IType::getTypeCode. |
||
18 | * |
||
19 | * @return TypeCode |
||
20 | */ |
||
21 | public function getTypeCode() |
||
25 | |||
26 | /** |
||
27 | * Checks this type is compatible with another type |
||
28 | * Note: implementation of IType::isCompatibleWith. |
||
29 | * |
||
30 | * @param IType $type Type to check compatibility |
||
31 | * |
||
32 | * @return bool |
||
33 | */ |
||
34 | public function isCompatibleWith(IType $type) |
||
38 | |||
39 | /** |
||
40 | * Validate a value in Astoria uri is in a format for this type |
||
41 | * Note: implementation of IType::validate. |
||
42 | * |
||
43 | * @param string $value The value to validate |
||
44 | * @param string &$outValue The stripped form of $value that can |
||
45 | * be used in PHP expressions |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function validate($value, &$outValue) |
||
80 | |||
81 | /** |
||
82 | * Gets full name of this type in EDM namespace |
||
83 | * Note: implementation of IType::getFullTypeName. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getFullTypeName() |
||
91 | |||
92 | /** |
||
93 | * Converts the given string value to datetime type. |
||
94 | * Note: This function will not perform any conversion. |
||
95 | * |
||
96 | * @param string $stringValue Value to convert |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function convert($stringValue) |
||
104 | |||
105 | /** |
||
106 | * Convert the given value to a form that can be used in OData uri. |
||
107 | * Note: The calling function should not pass null value, as this |
||
108 | * function will not perform any check for nullability. |
||
109 | * |
||
110 | * @param mixed $value Value to convert |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function convertToOData($value) |
||
118 | |||
119 | /** |
||
120 | * Gets year from datetime. |
||
121 | * |
||
122 | * @param string $dateTime datetime to get the year from |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public static function year($dateTime) |
||
132 | |||
133 | /** |
||
134 | * Gets month from datetime. |
||
135 | * |
||
136 | * @param string $dateTime datetime to get the month from |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public static function month($dateTime) |
||
146 | |||
147 | /** |
||
148 | * Gets day from datetime. |
||
149 | * |
||
150 | * @param string $dateTime datetime to get the day from |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | public static function day($dateTime) |
||
160 | |||
161 | /** |
||
162 | * Gets hour from datetime. |
||
163 | * |
||
164 | * @param string $dateTime datetime to get the hour from |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | public static function hour($dateTime) |
||
174 | |||
175 | /** |
||
176 | * Gets minute from datetime. |
||
177 | * |
||
178 | * @param string $dateTime datetime to get the minute from |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public static function minute($dateTime) |
||
188 | |||
189 | /** |
||
190 | * Gets second from datetime. |
||
191 | * |
||
192 | * @param string $dateTime datetime to get the second from |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public static function second($dateTime) |
||
202 | |||
203 | /** |
||
204 | * Compare two dates. Note that this function will not perform any |
||
205 | * validation on dates, one should use either validate or |
||
206 | * validateWithoutPrefix to validate the date before calling this |
||
207 | * function. |
||
208 | * |
||
209 | * @param string $dateTime1 First date |
||
210 | * @param string $dateTime2 Second date |
||
211 | * |
||
212 | * @return int |
||
213 | */ |
||
214 | public static function dateTimeCmp($dateTime1, $dateTime2) |
||
224 | |||
225 | /** |
||
226 | * Gets full name of the type implementing this interface in EDM namespace |
||
227 | * Note: implementation of IType::getFullTypeName. |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | public function getName() |
||
235 | |||
236 | protected static function dateTimeCmpCheckInput($dateTime, $msg) |
||
248 | } |
||
249 |