-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/intl: Timezone::getIanaID method addition. #13419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b022242
to
eea544d
Compare
no systems in CI supports icu >= 74 yet, but tested on my ubuntu 24.04 instance. |
ext/intl/timezone/timezone.stub.php
Outdated
@@ -112,6 +112,14 @@ public function getErrorMessage(): string|false {} | |||
*/ | |||
public static function getGMT(): IntlTimeZone {} | |||
|
|||
#if U_ICU_VERSION_MAJOR_NUM >= 74 | |||
/** | |||
* @tentative-return-type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to use a real return type because there is no BC impact of new methods (besides accidental collision iwth similarly named userland methods)
UnicodeString id; | ||
if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { | ||
intl_error_set(NULL, status, | ||
"intltz_get_iana_id: could not convert time zone id to UTF-16", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the actual function/method name can be retrieved via using get_active_function_or_method_name
b838a67
to
9f727a1
Compare
ext/intl/timezone/timezone.stub.php
Outdated
@@ -112,6 +112,14 @@ public function getErrorMessage(): string|false {} | |||
*/ | |||
public static function getGMT(): IntlTimeZone {} | |||
|
|||
#if U_ICU_VERSION_MAJOR_NUM >= 74 | |||
/** | |||
* @return string|false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary anymore :)
TimeZone::getIanaID(id, result, status); | ||
INTL_CHECK_STATUS(status, "intltz_get_iana_id: error obtaining IANA ID"); | ||
|
||
zend_string *u8str =intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), &status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit:
zend_string *u8str =intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), &status); | |
zend_string *u8str = intl_convert_utf16_to_utf8(result.getBuffer(), result.length(), &status); |
9f727a1
to
35b12b9
Compare
Warning: IntlTimeZone::getIanaID(): intltz_get_iana_id: could not convert time zone id to UTF-16 in %s on line %d | ||
bool(false) | ||
|
||
Warning: IntlTimeZone::getIanaID(): intltz_get_iana_id: error obtaining IANA ID in %s on line %d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot that the INTL warning mechanism is jank... Having intltz_get_iana_id:
is kinda pointless...
ping :) |
UnicodeString id; | ||
if (intl_stringFromChar(id, str_id, str_id_len, &status) == FAILURE) { | ||
intl_error_set(NULL, status, | ||
"intltz_get_iana_id: could not convert time zone id to UTF-16", 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"intltz_get_iana_id: could not convert time zone id to UTF-16", 0); | |
"could not convert time zone id to UTF-16", 0); |
This looks unneeded? Or if using the exception mode, then the message looks weird?
Also does this actually have a procedural equivalent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ; I was just trying to be consistent with the rest. However since it s master I ll do the same with the rest, not too much of a BC I don t think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think changing the error message is fine in master because it is somewhat weird.
35b12b9
to
3efc4a5
Compare
returns the primary IANA zone ID from the provided timezone ID. Most of the time, timezone ID==IANA ID. available from icu >= 74.
3efc4a5
to
9b582e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
returns the primary IANA zone ID from the provided timezone ID. Most of the time, timezone ID==IANA ID.
available from icu >= 74.