mirror of
https://github.com/php/php-src.git
synced 2026-10-29 18:24:57 +08:00
To be consistent with DateImmutable class, we add the possibility to set the calendar in a (real) proleptic gregorian via a new flag constant. For now, intention needs to be clear but can be made default eventually. Close GH-21101
34 lines
1.5 KiB
PHP
34 lines
1.5 KiB
PHP
--TEST--
|
|
IntlDateFormatter with invalid locale
|
|
--EXTENSIONS--
|
|
intl
|
|
--FILE--
|
|
<?php
|
|
|
|
$locale = 'en_US';
|
|
$timezone = 'GMT+05:12';
|
|
$type = IntlDateFormatter::FULL;
|
|
$invalidCalendar = -1;
|
|
|
|
try {
|
|
$df = new IntlDateFormatter($locale, $type, $type, $timezone, $invalidCalendar);
|
|
} catch (Throwable $e) {
|
|
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
|
}
|
|
|
|
$df = IntlDateFormatter::create($locale, $type, $type, $timezone, $invalidCalendar);
|
|
var_dump($df);
|
|
var_dump(intl_get_error_message());
|
|
|
|
$df = datefmt_create($locale, $type, $type, $timezone, $invalidCalendar);
|
|
var_dump($df);
|
|
var_dump(intl_get_error_message());
|
|
|
|
?>
|
|
--EXPECT--
|
|
IntlException: IntlDateFormatter::__construct(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN or IntlDateFormatter::PROLEPTIC_GREGORIAN. Alternatively, it can be an IntlCalendar object
|
|
NULL
|
|
string(287) "IntlDateFormatter::create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN or IntlDateFormatter::PROLEPTIC_GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|
|
NULL
|
|
string(276) "datefmt_create(): Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN or IntlDateFormatter::PROLEPTIC_GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
|