Skip to content

ext/intl: dateformatter settimezone changes on success, returning true #10790

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ PHP 8.3 UPGRADE NOTES
- Dom:
. Changed DOMCharacterData::appendData() tentative return type to true.

- Intl:
. datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone)
now returns true on sucess, previously null was returned.

- MBString:
. mb_strtolower, mb_strtotitle, and mb_convert_case implement conditional
casing rules for the Greek letter sigma. For mb_convert_case, conditional
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/dateformat/dateformat.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getTimeZone(): IntlTimeZone|false {}
* @tentative-return-type
* @alias datefmt_set_timezone
*/
public function setTimeZone($timezone): ?bool {} // TODO return true on success
public function setTimeZone($timezone): bool {}

/**
* @tentative-return-type
Expand Down
4 changes: 2 additions & 2 deletions ext/intl/dateformat/dateformat_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ext/intl/dateformat/dateformat_attrcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ U_CFUNC PHP_FUNCTION(datefmt_set_timezone)
}

fetch_datefmt(dfo)->adoptTimeZone(timezone);

RETURN_TRUE;
}

/* {{{ Get formatter calendar type. */
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/php_intl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function datefmt_get_calendar_object(IntlDateFormatter $formatter): IntlCalendar
function datefmt_get_timezone(IntlDateFormatter $formatter): IntlTimeZone|false {}

/** @param IntlTimeZone|DateTimeZone|string|null $timezone */
function datefmt_set_timezone(IntlDateFormatter $formatter, $timezone): ?bool {}
function datefmt_set_timezone(IntlDateFormatter $formatter, $timezone): bool {}

function datefmt_set_pattern(IntlDateFormatter $formatter, string $pattern): bool {}

Expand Down
4 changes: 2 additions & 2 deletions ext/intl/php_intl_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/intl/tests/dateformat_set_timezone_id2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ut_main()

$res_str .= "-----------";
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
if (ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ) !== true) die("ut_datefmt_set_timezone_id failed");
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
$formatted = ut_datefmt_format( $fmt, 0);
Expand Down
12 changes: 6 additions & 6 deletions ext/intl/tests/dateformat_set_timezone_id3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ ini_set("intl.error_level", E_WARNING);
function ut_main()
{
$timezone_id_arr = array (
'America/New_York',
'America/Los_Angeles',
'America/Chicago',
'CN'
'America/New_York' => true,
'America/Los_Angeles' => true,
'America/Chicago' => true,
'CN' => false
);
$timestamp_entry = 0;

Expand All @@ -33,12 +33,12 @@ function ut_main()
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";

foreach( $timezone_id_arr as $timezone_id_entry )
foreach( $timezone_id_arr as $timezone_id_entry => $result )
{

$res_str .= "-----------";
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
if (ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ) !== $result) die("ut_datefmt_set_timezone_id failed");
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
$formatted = ut_datefmt_format( $fmt, 0);
Expand Down
12 changes: 6 additions & 6 deletions ext/intl/tests/dateformat_set_timezone_id_icu72-1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ ini_set("intl.error_level", E_WARNING);
function ut_main()
{
$timezone_id_arr = array (
'America/New_York',
'America/Los_Angeles',
'America/Chicago',
'CN'
'America/New_York' => true,
'America/Los_Angeles' => true,
'America/Chicago' => true,
'CN' => false
);
$timestamp_entry = 0;

Expand All @@ -32,12 +32,12 @@ function ut_main()
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter creation of the dateformatter : timezone_id= $timezone_id\n";

foreach( $timezone_id_arr as $timezone_id_entry )
foreach( $timezone_id_arr as $timezone_id_entry => $result )
{

$res_str .= "-----------";
$res_str .= "\nTrying to set timezone_id= $timezone_id_entry";
ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry );
if (ut_datefmt_set_timezone_id( $fmt , $timezone_id_entry ) !== $result) die("ut_datefmt_set_timezone_id failed");
$timezone_id = ut_datefmt_get_timezone_id( $fmt );
$res_str .= "\nAfter call to set_timezone_id : timezone_id= $timezone_id";
$formatted = ut_datefmt_format( $fmt, 0);
Expand Down