Skip to content

Commit e6f66b2

Browse files
committed
dateformat ones
1 parent 0d681eb commit e6f66b2

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

ext/intl/tests/dateformat_calendars_variant3.phpt renamed to ext/intl/tests/dateformat_calendars_variant.phpt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ intl
88
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
99
--FILE--
1010
<?php
11-
ini_set("intl.error_level", E_WARNING);
1211

1312
$fmt1 = new IntlDateFormatter('en_US',
1413
IntlDateFormatter::FULL,
@@ -29,20 +28,8 @@ var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
2928
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
3029
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
3130

32-
new IntlDateFormatter('en_US@calendar=hebrew',
33-
IntlDateFormatter::FULL,
34-
IntlDateFormatter::FULL,
35-
'GMT+05:12',
36-
-1);
3731
?>
38-
==DONE==
39-
--EXPECTF--
32+
--EXPECT--
4033
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
4134
string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
4235
string(44) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"
43-
44-
Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant3.php:%d
45-
Stack trace:
46-
#0 %sdateformat_calendars_variant3.php(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
47-
#1 {main}
48-
thrown %sdateformat_calendars_variant3.php on line %d

ext/intl/tests/dateformat_calendars_variant_icu72-1.phpt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ intl
88
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
99
--FILE--
1010
<?php
11-
ini_set("intl.error_level", E_WARNING);
1211

1312
$fmt1 = new IntlDateFormatter('en_US',
1413
IntlDateFormatter::FULL,
@@ -29,20 +28,8 @@ var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
2928
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
3029
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));
3130

32-
new IntlDateFormatter('en_US@calendar=hebrew',
33-
IntlDateFormatter::FULL,
34-
IntlDateFormatter::FULL,
35-
'GMT+05:12',
36-
-1);
3731
?>
38-
==DONE==
39-
--EXPECTF--
32+
--EXPECT--
4033
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
4134
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
4235
string(46) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"
43-
44-
Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %s:%d
45-
Stack trace:
46-
#0 %s(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
47-
#1 {main}
48-
thrown in %s on line %d
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
IntlDateFormatter with invalid locale
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
$locale = 'en_US';
9+
$timezone = 'GMT+05:12';
10+
$type = IntlDateFormatter::FULL;
11+
$invalidCalendar = -1;
12+
13+
try {
14+
$df = new IntlDateFormatter($locale, $type, $type, $timezone, $invalidCalendar);
15+
} catch (Throwable $e) {
16+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
17+
}
18+
19+
$df = IntlDateFormatter::create($locale, $type, $type, $timezone, $invalidCalendar);
20+
var_dump($df);
21+
var_dump(intl_get_error_message());
22+
23+
$df = datefmt_create($locale, $type, $type, $timezone, $invalidCalendar);
24+
var_dump($df);
25+
var_dump(intl_get_error_message());
26+
27+
?>
28+
--EXPECT--
29+
IntlException: datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR
30+
NULL
31+
string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"
32+
NULL
33+
string(232) "datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object: U_ILLEGAL_ARGUMENT_ERROR"

ext/intl/tests/dateformat_format_error.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ intl
66
<?php
77

88
$locale = 'en_US';
9-
$timezone = 'GMT-10:00';
10-
$type = IntlDateFormatter::FULL;
119
$object = new stdClass();
1210

13-
$f = new IntlDateFormatter($locale, $type, $type, $timezone, IntlDateFormatter::GREGORIAN);
11+
$f = new IntlDateFormatter($locale);
1412

1513
$v = $f->format($object);
1614
var_dump($v);

0 commit comments

Comments
 (0)