U_CFUNC PHP_FUNCTION(intltz_get_id) { TIMEZONE_METHOD_INIT_VARS; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, TimeZone_ce_ptr) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_get_id: bad arguments", 0 TSRMLS_CC); RETURN_FALSE; } TIMEZONE_METHOD_FETCH_OBJECT; UnicodeString id_us; to->utimezone->getID(id_us); char *id = NULL; int id_len = 0; intl_convert_utf16_to_utf8(&id, &id_len, id_us.getBuffer(), id_us.length(), TIMEZONE_ERROR_CODE_P(to)); INTL_METHOD_CHECK_STATUS(to, "intltz_get_id: Could not convert id to UTF-8"); RETURN_STRINGL(id, id_len, 0); }
U_CFUNC PHP_FUNCTION(intltz_get_display_name) { zend_bool daylight = 0; zend_long display_type = TimeZone::LONG; const char *locale_str = NULL; size_t dummy = 0; TIMEZONE_METHOD_INIT_VARS; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|bls!", &object, TimeZone_ce_ptr, &daylight, &display_type, &locale_str, &dummy) == FAILURE) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_get_display_name: bad arguments", 0); RETURN_FALSE; } bool found = false; for (int i = 0; !found && i < sizeof(display_types)/sizeof(*display_types); i++) { if (display_types[i] == display_type) found = true; } if (!found) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "intltz_get_display_name: wrong display type", 0); RETURN_FALSE; } if (!locale_str) { locale_str = intl_locale_get_default(); } TIMEZONE_METHOD_FETCH_OBJECT; UnicodeString result; to->utimezone->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)display_type, Locale::createFromName(locale_str), result); char *str; int str_len; intl_convert_utf16_to_utf8(&str, &str_len, result.getBuffer(), result.length(), TIMEZONE_ERROR_CODE_P(to)); INTL_METHOD_CHECK_STATUS(to, "intltz_get_display_name: " "could not convert resulting time zone id to UTF-16"); RETVAL_STRINGL(str, str_len); //???? efree(str); }