ext/intl: expose dateformat UDAT_PATTERN constant.

Close GH-12258
This commit is contained in:
David Carlier 2023-09-21 05:51:52 +01:00
parent 62e2402534
commit f6fae19a10
5 changed files with 20 additions and 3 deletions

3
NEWS
View file

@ -8,6 +8,9 @@ Core:
DOM: DOM:
. Added DOMNode::compareDocumentPosition(). (nielsdos) . Added DOMNode::compareDocumentPosition(). (nielsdos)
Intl:
. Added IntlDateFormatter::PATTERN constant. (David Carlier)
Standard: Standard:
. Implement GH-12188 (Indication for the int size in phpinfo()). (timwolla) . Implement GH-12188 (Indication for the int size in phpinfo()). (timwolla)
. Partly fix GH-12143 (Incorrect round() result for 0.49999999999999994). . Partly fix GH-12143 (Incorrect round() result for 0.49999999999999994).

View file

@ -82,6 +82,10 @@ PHP 8.4 UPGRADE NOTES
10. New Global Constants 10. New Global Constants
======================================== ========================================
- Intl:
. The IntlDateFormatter class exposes now the new PATTERN constant
reflecting udat api's UDAT_PATTERN.
======================================== ========================================
11. Changes to INI File Handling 11. Changes to INI File Handling
======================================== ========================================

View file

@ -50,6 +50,11 @@ class IntlDateFormatter
* @cvalue UDAT_SHORT_RELATIVE * @cvalue UDAT_SHORT_RELATIVE
*/ */
public const RELATIVE_SHORT = UNKNOWN; public const RELATIVE_SHORT = UNKNOWN;
/**
* @var int
* @cvalue UDAT_PATTERN
*/
public const PATTERN = UNKNOWN;
/** /**
* @var int * @var int

View file

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead. /* This is a generated file, edit the .stub.php file instead.
* Stub hash: c3aabab98e4864276f6cb0afb2e3fefad0386481 */ * Stub hash: c7bec57da82aab1f4470df0f2b725523885a58c2 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1) ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
@ -197,6 +197,12 @@ static zend_class_entry *register_class_IntlDateFormatter(void)
zend_declare_class_constant_ex(class_entry, const_RELATIVE_SHORT_name, &const_RELATIVE_SHORT_value, ZEND_ACC_PUBLIC, NULL); zend_declare_class_constant_ex(class_entry, const_RELATIVE_SHORT_name, &const_RELATIVE_SHORT_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_RELATIVE_SHORT_name); zend_string_release(const_RELATIVE_SHORT_name);
zval const_PATTERN_value;
ZVAL_LONG(&const_PATTERN_value, UDAT_PATTERN);
zend_string *const_PATTERN_name = zend_string_init_interned("PATTERN", sizeof("PATTERN") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_PATTERN_name, &const_PATTERN_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_PATTERN_name);
zval const_GREGORIAN_value; zval const_GREGORIAN_value;
ZVAL_LONG(&const_GREGORIAN_value, UCAL_GREGORIAN); ZVAL_LONG(&const_GREGORIAN_value, UCAL_GREGORIAN);
zend_string *const_GREGORIAN_name = zend_string_init_interned("GREGORIAN", sizeof("GREGORIAN") - 1, 1); zend_string *const_GREGORIAN_name = zend_string_init_interned("GREGORIAN", sizeof("GREGORIAN") - 1, 1);

View file

@ -7,12 +7,11 @@ intl
<?php <?php
$datetime = new \DateTime('2017-05-12 23:11:00 GMT+2'); $datetime = new \DateTime('2017-05-12 23:11:00 GMT+2');
static $UDAT_PATTERN = -2;
try { try {
new IntlDateFormatter( new IntlDateFormatter(
locale: 'en', locale: 'en',
dateType: $UDAT_PATTERN, dateType: IntlDateFormatter::PATTERN,
timeType: 0, timeType: 0,
timezone: $datetime->getTimezone(), timezone: $datetime->getTimezone(),
); );