1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | http://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Gustavo Lopes <cataphract@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include "../intl_cppshims.h"
23
24 #include <unicode/timezone.h>
25 #include <unicode/calendar.h>
26 #include "../intl_convertcpp.h"
27
28 #include "../common/common_date.h"
29
30 extern "C" {
31 #include "../intl_convert.h"
32 #define USE_TIMEZONE_POINTER 1
33 #include "timezone_class.h"
34 #include "timezone_methods.h"
35 #include <zend_exceptions.h>
36 #include <zend_interfaces.h>
37 #include <ext/date/php_date.h>
38 }
39
40 /* {{{ Global variables */
41 U_CDECL_BEGIN
42 zend_class_entry *TimeZone_ce_ptr = NULL;
43 zend_object_handlers TimeZone_handlers;
44 U_CDECL_END
45 /* }}} */
46
47 /* {{{ timezone_object_construct */
timezone_object_construct(const TimeZone * zone,zval * object,int owned)48 U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int owned)
49 {
50 TimeZone_object *to;
51
52 object_init_ex(object, TimeZone_ce_ptr);
53 TIMEZONE_METHOD_FETCH_OBJECT_NO_CHECK; /* fetch zend object from zval "object" into "to" */
54 to->utimezone = zone;
55 to->should_delete = owned;
56 }
57 /* }}} */
58
59 /* {{{ timezone_convert_to_datetimezone
60 * Convert from TimeZone to DateTimeZone object */
timezone_convert_to_datetimezone(const TimeZone * timeZone,intl_error * outside_error,const char * func,zval * ret)61 U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
62 intl_error *outside_error,
63 const char *func, zval *ret)
64 {
65 UnicodeString id;
66 char *message = NULL;
67 php_timezone_obj *tzobj;
68 zval arg;
69
70 timeZone->getID(id);
71 if (id.isBogus()) {
72 spprintf(&message, 0, "%s: could not obtain TimeZone id", func);
73 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
74 message, 1);
75 goto error;
76 }
77
78 object_init_ex(ret, php_date_get_timezone_ce());
79 tzobj = Z_PHPTIMEZONE_P(ret);
80
81 if (id.compare(0, 3, UnicodeString("GMT", sizeof("GMT")-1, US_INV)) == 0) {
82 /* The DateTimeZone constructor doesn't support offset time zones,
83 * so we must mess with DateTimeZone structure ourselves */
84 tzobj->initialized = 1;
85 tzobj->type = TIMELIB_ZONETYPE_OFFSET;
86 //convert offset from milliseconds to minutes
87 tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 1000);
88 } else {
89 zend_string *u8str;
90 /* Call the constructor! */
91 u8str = intl_charFromString(id, &INTL_ERROR_CODE(*outside_error));
92 if (!u8str) {
93 spprintf(&message, 0, "%s: could not convert id to UTF-8", func);
94 intl_errors_set(outside_error, INTL_ERROR_CODE(*outside_error),
95 message, 1);
96 goto error;
97 }
98 ZVAL_STR(&arg, u8str);
99 zend_call_method_with_1_params(ret, NULL, NULL, "__construct", NULL, &arg);
100 if (EG(exception)) {
101 spprintf(&message, 0,
102 "%s: DateTimeZone constructor threw exception", func);
103 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
104 message, 1);
105 zend_object_store_ctor_failed(Z_OBJ_P(ret));
106 zval_ptr_dtor(&arg);
107 goto error;
108 }
109 zval_ptr_dtor(&arg);
110 }
111
112 if (0) {
113 error:
114 if (ret) {
115 zval_ptr_dtor(ret);
116 }
117 ret = NULL;
118 }
119
120 if (message) {
121 efree(message);
122 }
123 return ret;
124 }
125 /* }}} */
126
127 /* {{{ timezone_process_timezone_argument
128 * TimeZone argument processor. outside_error may be NULL (for static functions/constructors) */
timezone_process_timezone_argument(zval * zv_timezone,intl_error * outside_error,const char * func)129 U_CFUNC TimeZone *timezone_process_timezone_argument(zval *zv_timezone,
130 intl_error *outside_error,
131 const char *func)
132 {
133 zval local_zv_tz;
134 char *message = NULL;
135 TimeZone *timeZone;
136
137 if (zv_timezone == NULL || Z_TYPE_P(zv_timezone) == IS_NULL) {
138 timelib_tzinfo *tzinfo = get_timezone_info();
139 ZVAL_STRING(&local_zv_tz, tzinfo->name);
140 zv_timezone = &local_zv_tz;
141 } else {
142 ZVAL_NULL(&local_zv_tz);
143 }
144
145 if (Z_TYPE_P(zv_timezone) == IS_OBJECT &&
146 instanceof_function(Z_OBJCE_P(zv_timezone), TimeZone_ce_ptr)) {
147 TimeZone_object *to = Z_INTL_TIMEZONE_P(zv_timezone);
148 if (to->utimezone == NULL) {
149 spprintf(&message, 0, "%s: passed IntlTimeZone is not "
150 "properly constructed", func);
151 if (message) {
152 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
153 efree(message);
154 }
155 zval_dtor(&local_zv_tz);
156 return NULL;
157 }
158 timeZone = to->utimezone->clone();
159 if (timeZone == NULL) {
160 spprintf(&message, 0, "%s: could not clone TimeZone", func);
161 if (message) {
162 intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1);
163 efree(message);
164 }
165 zval_dtor(&local_zv_tz);
166 return NULL;
167 }
168 } else if (Z_TYPE_P(zv_timezone) == IS_OBJECT &&
169 instanceof_function(Z_OBJCE_P(zv_timezone), php_date_get_timezone_ce())) {
170
171 php_timezone_obj *tzobj = Z_PHPTIMEZONE_P(zv_timezone);
172
173 zval_dtor(&local_zv_tz);
174 return timezone_convert_datetimezone(tzobj->type, tzobj, 0,
175 outside_error, func);
176 } else {
177 UnicodeString id,
178 gottenId;
179 UErrorCode status = U_ZERO_ERROR; /* outside_error may be NULL */
180 convert_to_string_ex(zv_timezone);
181 if (intl_stringFromChar(id, Z_STRVAL_P(zv_timezone), Z_STRLEN_P(zv_timezone),
182 &status) == FAILURE) {
183 spprintf(&message, 0, "%s: Time zone identifier given is not a "
184 "valid UTF-8 string", func);
185 if (message) {
186 intl_errors_set(outside_error, status, message, 1);
187 efree(message);
188 }
189 zval_dtor(&local_zv_tz);
190 return NULL;
191 }
192 timeZone = TimeZone::createTimeZone(id);
193 if (timeZone == NULL) {
194 spprintf(&message, 0, "%s: could not create time zone", func);
195 if (message) {
196 intl_errors_set(outside_error, U_MEMORY_ALLOCATION_ERROR, message, 1);
197 efree(message);
198 }
199 zval_dtor(&local_zv_tz);
200 return NULL;
201 }
202 if (timeZone->getID(gottenId) != id) {
203 spprintf(&message, 0, "%s: no such time zone: '%s'",
204 func, Z_STRVAL_P(zv_timezone));
205 if (message) {
206 intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR, message, 1);
207 efree(message);
208 }
209 zval_dtor(&local_zv_tz);
210 delete timeZone;
211 return NULL;
212 }
213 }
214
215 zval_dtor(&local_zv_tz);
216
217 return timeZone;
218 }
219 /* }}} */
220
221 /* {{{ clone handler for TimeZone */
TimeZone_clone_obj(zval * object)222 static zend_object *TimeZone_clone_obj(zval *object)
223 {
224 TimeZone_object *to_orig,
225 *to_new;
226 zend_object *ret_val;
227 intl_error_reset(NULL);
228
229 to_orig = Z_INTL_TIMEZONE_P(object);
230 intl_error_reset(TIMEZONE_ERROR_P(to_orig));
231
232 ret_val = TimeZone_ce_ptr->create_object(Z_OBJCE_P(object));
233 to_new = php_intl_timezone_fetch_object(ret_val);
234
235 zend_objects_clone_members(&to_new->zo, &to_orig->zo);
236
237 if (to_orig->utimezone != NULL) {
238 TimeZone *newTimeZone;
239
240 newTimeZone = to_orig->utimezone->clone();
241 to_new->should_delete = 1;
242 if (!newTimeZone) {
243 zend_string *err_msg;
244 intl_errors_set_code(TIMEZONE_ERROR_P(to_orig),
245 U_MEMORY_ALLOCATION_ERROR);
246 intl_errors_set_custom_msg(TIMEZONE_ERROR_P(to_orig),
247 "Could not clone IntlTimeZone", 0);
248 err_msg = intl_error_get_message(TIMEZONE_ERROR_P(to_orig));
249 zend_throw_exception(NULL, ZSTR_VAL(err_msg), 0);
250 zend_string_free(err_msg);
251 } else {
252 to_new->utimezone = newTimeZone;
253 }
254 } else {
255 zend_throw_exception(NULL, "Cannot clone unconstructed IntlTimeZone", 0);
256 }
257
258 return ret_val;
259 }
260 /* }}} */
261
262 /* {{{ compare_objects handler for TimeZone
263 * Can't be used for >, >=, <, <= comparisons */
TimeZone_compare_objects(zval * object1,zval * object2)264 static int TimeZone_compare_objects(zval *object1, zval *object2)
265 {
266 TimeZone_object *to1,
267 *to2;
268 to1 = Z_INTL_TIMEZONE_P(object1);
269 to2 = Z_INTL_TIMEZONE_P(object2);
270
271 if (to1->utimezone == NULL || to2->utimezone == NULL) {
272 zend_throw_exception(NULL, "Comparison with at least one unconstructed "
273 "IntlTimeZone operand", 0);
274 /* intentionally not returning */
275 } else {
276 if (*to1->utimezone == *to2->utimezone) {
277 return 0;
278 }
279 }
280
281 return 1;
282 }
283 /* }}} */
284
285 /* {{{ get_debug_info handler for TimeZone */
TimeZone_get_debug_info(zval * object,int * is_temp)286 static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp)
287 {
288 zval zv;
289 TimeZone_object *to;
290 const TimeZone *tz;
291 UnicodeString ustr;
292 zend_string *u8str;
293 HashTable *debug_info;
294 UErrorCode uec = U_ZERO_ERROR;
295
296 *is_temp = 1;
297
298 ALLOC_HASHTABLE(debug_info);
299 zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0);
300
301 to = Z_INTL_TIMEZONE_P(object);
302 tz = to->utimezone;
303
304 if (tz == NULL) {
305 ZVAL_FALSE(&zv);
306 zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
307 return debug_info;
308 }
309
310 ZVAL_TRUE(&zv);
311 zend_hash_str_update(debug_info, "valid", sizeof("valid") - 1, &zv);
312
313 tz->getID(ustr);
314 u8str = intl_convert_utf16_to_utf8(
315 ustr.getBuffer(), ustr.length(), &uec);
316 if (!u8str) {
317 return debug_info;
318 }
319 ZVAL_NEW_STR(&zv, u8str);
320 zend_hash_str_update(debug_info, "id", sizeof("id") - 1, &zv);
321
322 int32_t rawOffset, dstOffset;
323 UDate now = Calendar::getNow();
324 tz->getOffset(now, FALSE, rawOffset, dstOffset, uec);
325 if (U_FAILURE(uec)) {
326 return debug_info;
327 }
328
329 ZVAL_LONG(&zv, (zend_long)rawOffset);
330 zend_hash_str_update(debug_info,"rawOffset", sizeof("rawOffset") - 1, &zv);
331 ZVAL_LONG(&zv, (zend_long)(rawOffset + dstOffset));
332 zend_hash_str_update(debug_info,"currentOffset", sizeof("currentOffset") - 1, &zv);
333
334 return debug_info;
335 }
336 /* }}} */
337
338 /* {{{ void TimeZone_object_init(TimeZone_object* to)
339 * Initialize internals of TImeZone_object not specific to zend standard objects.
340 */
TimeZone_object_init(TimeZone_object * to)341 static void TimeZone_object_init(TimeZone_object *to)
342 {
343 intl_error_init(TIMEZONE_ERROR_P(to));
344 to->utimezone = NULL;
345 to->should_delete = 0;
346 }
347 /* }}} */
348
349 /* {{{ TimeZone_objects_dtor */
TimeZone_objects_dtor(zend_object * object)350 static void TimeZone_objects_dtor(zend_object *object)
351 {
352 zend_objects_destroy_object(object);
353 }
354 /* }}} */
355
356 /* {{{ TimeZone_objects_free */
TimeZone_objects_free(zend_object * object)357 static void TimeZone_objects_free(zend_object *object)
358 {
359 TimeZone_object* to = php_intl_timezone_fetch_object(object);
360
361 if (to->utimezone && to->should_delete) {
362 delete to->utimezone;
363 to->utimezone = NULL;
364 }
365 intl_error_reset(TIMEZONE_ERROR_P(to));
366
367 zend_object_std_dtor(&to->zo);
368 }
369 /* }}} */
370
371 /* {{{ TimeZone_object_create */
TimeZone_object_create(zend_class_entry * ce)372 static zend_object *TimeZone_object_create(zend_class_entry *ce)
373 {
374 TimeZone_object* intern;
375
376 intern = (TimeZone_object*)ecalloc(1, sizeof(TimeZone_object) + sizeof(zval) * (ce->default_properties_count - 1));
377
378 zend_object_std_init(&intern->zo, ce);
379 object_properties_init(&intern->zo, ce);
380 TimeZone_object_init(intern);
381
382 intern->zo.handlers = &TimeZone_handlers;
383
384 return &intern->zo;
385 }
386 /* }}} */
387
388 /* {{{ TimeZone methods arguments info */
389
390 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_idarg, 0, 0, 1)
391 ZEND_ARG_INFO(0, zoneId)
392 ZEND_END_ARG_INFO()
393
394 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_fromDateTimeZone, 0, 0, 1)
395 ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0)
396 ZEND_END_ARG_INFO()
397
398 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createEnumeration, 0, 0, 0)
399 ZEND_ARG_INFO(0, countryOrRawOffset)
400 ZEND_END_ARG_INFO()
401
402 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_countEquivalentIDs, 0, 0, 1)
403 ZEND_ARG_INFO(0, zoneId)
404 ZEND_END_ARG_INFO()
405
406 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_createTimeZoneIDEnumeration, 0, 0, 1)
407 ZEND_ARG_INFO(0, zoneType)
408 ZEND_ARG_INFO(0, region)
409 ZEND_ARG_INFO(0, rawOffset)
410 ZEND_END_ARG_INFO()
411
412 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getCanonicalID, 0, 0, 1)
413 ZEND_ARG_INFO(0, zoneId)
414 ZEND_ARG_INFO(1, isSystemID)
415 ZEND_END_ARG_INFO()
416
417 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getEquivalentID, 0, 0, 2)
418 ZEND_ARG_INFO(0, zoneId)
419 ZEND_ARG_INFO(0, index)
420 ZEND_END_ARG_INFO()
421
422 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getOffset, 0, 0, 4)
423 ZEND_ARG_INFO(0, date)
424 ZEND_ARG_INFO(0, local)
425 ZEND_ARG_INFO(1, rawOffset)
426 ZEND_ARG_INFO(1, dstOffset)
427 ZEND_END_ARG_INFO()
428
429 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_hasSameRules, 0, 0, 1)
430 ZEND_ARG_OBJ_INFO(0, otherTimeZone, IntlTimeZone, 0)
431 ZEND_END_ARG_INFO()
432
433 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getDisplayName, 0, 0, 0)
434 ZEND_ARG_INFO(0, isDaylight)
435 ZEND_ARG_INFO(0, style)
436 ZEND_ARG_INFO(0, locale)
437 ZEND_END_ARG_INFO()
438
439 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_void, 0, 0, 0)
440 ZEND_END_ARG_INFO()
441
442 #if U_ICU_VERSION_MAJOR_NUM >= 52
443 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getWindowsID, 0, ZEND_RETURN_VALUE, 1)
444 ZEND_ARG_INFO(0, timezone)
445 ZEND_END_ARG_INFO()
446
447 ZEND_BEGIN_ARG_INFO_EX(ainfo_tz_getIDForWindowsID, 0, ZEND_RETURN_VALUE, 1)
448 ZEND_ARG_INFO(0, timezone)
449 ZEND_ARG_INFO(0, region)
450 ZEND_END_ARG_INFO()
451 #endif
452
453 /* }}} */
454
455 /* {{{ TimeZone_class_functions
456 * Every 'IntlTimeZone' class method has an entry in this table
457 */
458 static zend_function_entry TimeZone_class_functions[] = {
459 PHP_ME(IntlTimeZone, __construct, ainfo_tz_void, ZEND_ACC_PRIVATE)
460 PHP_ME_MAPPING(createTimeZone, intltz_create_time_zone, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
461 PHP_ME_MAPPING(fromDateTimeZone, intltz_from_date_time_zone, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
462 PHP_ME_MAPPING(createDefault, intltz_create_default, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
463 PHP_ME_MAPPING(getGMT, intltz_get_gmt, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
464 #if U_ICU_VERSION_MAJOR_NUM >= 49
465 PHP_ME_MAPPING(getUnknown, intltz_get_unknown, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
466 #endif
467 PHP_ME_MAPPING(createEnumeration, intltz_create_enumeration, ainfo_tz_createEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
468 PHP_ME_MAPPING(countEquivalentIDs, intltz_count_equivalent_ids, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
469 #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
470 PHP_ME_MAPPING(createTimeZoneIDEnumeration, intltz_create_time_zone_id_enumeration, ainfo_tz_createTimeZoneIDEnumeration, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
471 #endif
472 PHP_ME_MAPPING(getCanonicalID, intltz_get_canonical_id, ainfo_tz_getCanonicalID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
473 #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
474 PHP_ME_MAPPING(getRegion, intltz_get_region, ainfo_tz_idarg, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
475 #endif
476 PHP_ME_MAPPING(getTZDataVersion, intltz_get_tz_data_version, ainfo_tz_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
477 PHP_ME_MAPPING(getEquivalentID, intltz_get_equivalent_id, ainfo_tz_getEquivalentID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
478
479 PHP_ME_MAPPING(getID, intltz_get_id, ainfo_tz_void, ZEND_ACC_PUBLIC)
480 PHP_ME_MAPPING(useDaylightTime, intltz_use_daylight_time, ainfo_tz_void, ZEND_ACC_PUBLIC)
481 PHP_ME_MAPPING(getOffset, intltz_get_offset, ainfo_tz_getOffset, ZEND_ACC_PUBLIC)
482 PHP_ME_MAPPING(getRawOffset, intltz_get_raw_offset, ainfo_tz_void, ZEND_ACC_PUBLIC)
483 PHP_ME_MAPPING(hasSameRules, intltz_has_same_rules, ainfo_tz_hasSameRules, ZEND_ACC_PUBLIC)
484 PHP_ME_MAPPING(getDisplayName, intltz_get_display_name, ainfo_tz_getDisplayName, ZEND_ACC_PUBLIC)
485 PHP_ME_MAPPING(getDSTSavings, intltz_get_dst_savings, ainfo_tz_void, ZEND_ACC_PUBLIC)
486 PHP_ME_MAPPING(toDateTimeZone, intltz_to_date_time_zone, ainfo_tz_void, ZEND_ACC_PUBLIC)
487 PHP_ME_MAPPING(getErrorCode, intltz_get_error_code, ainfo_tz_void, ZEND_ACC_PUBLIC)
488 PHP_ME_MAPPING(getErrorMessage, intltz_get_error_message, ainfo_tz_void, ZEND_ACC_PUBLIC)
489 #if U_ICU_VERSION_MAJOR_NUM >= 52
490 PHP_ME_MAPPING(getWindowsID, intltz_get_windows_id, ainfo_tz_getWindowsID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
491 PHP_ME_MAPPING(getIDForWindowsID, intltz_get_id_for_windows_id, ainfo_tz_getIDForWindowsID, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
492 #endif
493 PHP_FE_END
494 };
495 /* }}} */
496
497 /* {{{ timezone_register_IntlTimeZone_class
498 * Initialize 'IntlTimeZone' class
499 */
timezone_register_IntlTimeZone_class(void)500 U_CFUNC void timezone_register_IntlTimeZone_class(void)
501 {
502 zend_class_entry ce;
503
504 /* Create and register 'IntlTimeZone' class. */
505 INIT_CLASS_ENTRY(ce, "IntlTimeZone", TimeZone_class_functions);
506 ce.create_object = TimeZone_object_create;
507 TimeZone_ce_ptr = zend_register_internal_class(&ce);
508 if (!TimeZone_ce_ptr) {
509 //can't happen now without bigger problems before
510 php_error_docref0(NULL, E_ERROR,
511 "IntlTimeZone: class registration has failed.");
512 return;
513 }
514
515 memcpy(&TimeZone_handlers, zend_get_std_object_handlers(),
516 sizeof TimeZone_handlers);
517 TimeZone_handlers.offset = XtOffsetOf(TimeZone_object, zo);
518 TimeZone_handlers.clone_obj = TimeZone_clone_obj;
519 TimeZone_handlers.compare_objects = TimeZone_compare_objects;
520 TimeZone_handlers.get_debug_info = TimeZone_get_debug_info;
521 TimeZone_handlers.dtor_obj = TimeZone_objects_dtor;
522 TimeZone_handlers.free_obj = TimeZone_objects_free;
523
524
525 /* Declare 'IntlTimeZone' class constants */
526 #define TIMEZONE_DECL_LONG_CONST(name, val) \
527 zend_declare_class_constant_long(TimeZone_ce_ptr, name, sizeof(name) - 1, \
528 val)
529
530 TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT", TimeZone::SHORT);
531 TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG", TimeZone::LONG);
532
533 #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 44
534 TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GENERIC", TimeZone::SHORT_GENERIC);
535 TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GENERIC", TimeZone::LONG_GENERIC);
536 TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_GMT", TimeZone::SHORT_GMT);
537 TIMEZONE_DECL_LONG_CONST("DISPLAY_LONG_GMT", TimeZone::LONG_GMT);
538 TIMEZONE_DECL_LONG_CONST("DISPLAY_SHORT_COMMONLY_USED", TimeZone::SHORT_COMMONLY_USED);
539 TIMEZONE_DECL_LONG_CONST("DISPLAY_GENERIC_LOCATION", TimeZone::GENERIC_LOCATION);
540 #endif
541
542 #if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
543 TIMEZONE_DECL_LONG_CONST("TYPE_ANY", UCAL_ZONE_TYPE_ANY);
544 TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL", UCAL_ZONE_TYPE_CANONICAL);
545 TIMEZONE_DECL_LONG_CONST("TYPE_CANONICAL_LOCATION", UCAL_ZONE_TYPE_CANONICAL_LOCATION);
546 #endif
547
548 /* Declare 'IntlTimeZone' class properties */
549
550 }
551 /* }}} */
552