Skip to content

ext/intl: Allow numeric-castable objects as date/time values in IntlDateFormatter->format()#21959

Open
LamentXU123 wants to merge 5 commits intophp:masterfrom
LamentXU123:clean-up-
Open

ext/intl: Allow numeric-castable objects as date/time values in IntlDateFormatter->format()#21959
LamentXU123 wants to merge 5 commits intophp:masterfrom
LamentXU123:clean-up-

Conversation

@LamentXU123
Copy link
Copy Markdown
Contributor

@LamentXU123 LamentXU123 commented May 6, 2026

Allow IntlDateFormatter->format() to accept objects that support numeric casting, in addition to IntlCalendar and DateTimeInterface as per the TODO message.

@LamentXU123 LamentXU123 changed the title ext/intl: Allow numeric-castable objects as date/time values in IntlDateFormatter::formatObject() ext/intl: Allow numeric-castable objects as date/time values in IntlDateFormatter->format() May 6, 2026
rv = U_MILLIS_PER_SECOND * (double)Z_LVAL(casted);
} else if (Z_TYPE(casted) == IS_DOUBLE) {
rv = U_MILLIS_PER_SECOND * Z_DVAL(casted);
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to gate it with !EG(exception)

Copy link
Copy Markdown
Contributor Author

@LamentXU123 LamentXU123 May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good catch :) Please check it again and see if now its right enough.

Comment thread ext/intl/tests/dateformat_formatObject_numeric_object.phpt
Comment thread ext/intl/tests/dateformat_format_error.phpt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants