Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions ext/intl/tests/dateformat_calendars_variant3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ date.timezone=Atlantic/Azores
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '54.1') < 0) die('skip for ICU >= 54.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
Expand Down
48 changes: 48 additions & 0 deletions ext/intl/tests/dateformat_calendars_variant4.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--TEST--
IntlDateFormatter, calendars and time zone
--INI--
date.timezone=Atlantic/Azores
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);

$fmt1 = new IntlDateFormatter('en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::TRADITIONAL);
$fmt2 = new IntlDateFormatter('en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::GREGORIAN);
$fmt3 = new IntlDateFormatter('en_US@calendar=hebrew',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
IntlDateFormatter::TRADITIONAL);
var_dump($fmt1->format(strtotime('2012-01-01 00:00:00 +0000')));
var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000')));
var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000')));

new IntlDateFormatter('en_US@calendar=hebrew',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'GMT+05:12',
-1);
?>
==DONE==
--EXPECTF--
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(49) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12"
string(46) "Sunday, 6 Tevet 5772 at 5:12:00 AM GMT+05:12"

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
Stack trace:
#0 %s(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1)
#1 {main}
thrown in %s on line %d
2 changes: 2 additions & 0 deletions ext/intl/tests/dateformat_create_default.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ IntlDateFormatter::create() with default date and time types
intl
--INI--
date.timezone=UTC
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php

Expand Down
26 changes: 26 additions & 0 deletions ext/intl/tests/dateformat_create_default2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
IntlDateFormatter::create() with default date and time types
--EXTENSIONS--
intl
--INI--
date.timezone=UTC
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
--FILE--
<?php

$ts = strtotime('2012-01-01 00:00:00 UTC');
$fmt = IntlDateFormatter::create('en_US');
echo $fmt->format($ts), "\n";

$fmt = new IntlDateFormatter('en_US');
echo $fmt->format($ts), "\n";

$fmt = datefmt_create('en_US');
echo $fmt->format($ts), "\n";

?>
--EXPECT--
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
Sunday, January 1, 2012 at 12:00:00 AM Coordinated Universal Time
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): IntlCalendar tests
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
Expand Down
37 changes: 37 additions & 0 deletions ext/intl/tests/dateformat_formatObject_calendar_variant6.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--TEST--
IntlDateFormatter::formatObject(): IntlCalendar tests
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU >= 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", "Europe/Lisbon");

$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
echo IntlDateFormatter::formatObject($cal), "\n";
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";

$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";

$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
echo IntlDateFormatter::formatObject($cal), "\n";
echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";

?>
--EXPECTF--
01/01/2012, 00:00:00
domingo, 1 de janeiro de 2012 às 00:00:00 Hora padrão %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
1/1/12, 12:00:00 AM Western European Standard Time
Sun 2012-01-1 00,00,00.000 Portugal Time
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
06/02/1433, 00:00:00
Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ IntlDateFormatter::formatObject(): DateTime tests
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '55.1') < 0) die('skip for ICU >= 55.1'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
Expand Down
30 changes: 30 additions & 0 deletions ext/intl/tests/dateformat_formatObject_datetime_variant6.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
IntlDateFormatter::formatObject(): DateTime tests
--EXTENSIONS--
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '72.1') < 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", "Europe/Lisbon");

$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
echo IntlDateFormatter::formatObject($dt), "\n";
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";

$dt = new DateTime('2012-01-01 05:00:00+03:00');
echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";

?>
--EXPECTF--
01/01/2012, 00:00:00
domingo, 1 de janeiro de 2012 às 00:00:00 Hora padrão %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
1/1/12, 12:00:00 AM Western European Standard Time
Sun 2012-01-1 00,00,00.000 Portugal Time
domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00
1 change: 1 addition & 0 deletions ext/intl/tests/dateformat_format_parse_version2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ datefmt_format_code() and datefmt_parse_code()
intl
--SKIPIF--
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0) die('skip for ICU >= 51.2'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '72.1') >= 0) die('skip for ICU < 72.1'); ?>
--FILE--
<?php

Expand Down
Loading