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