php-src/ext/intl/tests/dateformat_get_set_calendar.phpt

56 lines
1.2 KiB
Plaintext
Raw Normal View History

2008-07-07 22:51:04 +00:00
--TEST--
2012-06-03 22:02:35 +00:00
IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject()
--SKIPIF--
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
2008-07-07 22:51:04 +00:00
--FILE--
<?php
2012-06-03 22:02:35 +00:00
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
ini_set("date.timezone", 'Atlantic/Azores');
$ts = strtotime('2012-01-01 00:00:00 UTC');
function d(IntlDateFormatter $df) {
global $ts;
echo $df->format($ts), "\n";
var_dump($df->getCalendar(),
$df->getCalendarObject()->getType(),
$df->getCalendarObject()->getTimeZone()->getId());
echo "\n";
}
2008-07-07 22:51:04 +00:00
2012-06-03 22:02:35 +00:00
$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk');
d($df);
2008-07-07 22:51:04 +00:00
2012-06-03 22:02:35 +00:00
//changing the calendar with a cal type should not change tz
$df->setCalendar(IntlDateFormatter::TRADITIONAL);
d($df);
//but changing with an actual calendar should
$cal = IntlCalendar::createInstance("UTC");
$df->setCalendar($cal);
d($df);
2008-07-07 22:51:04 +00:00
?>
2012-06-03 22:02:35 +00:00
==DONE==
2008-07-07 22:51:04 +00:00
--EXPECT--
2012-06-03 22:02:35 +00:00
dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00
int(1)
string(9) "gregorian"
string(12) "Europe/Minsk"
dimanche 8 Safar 1433 AH 03:00:00 UTC+03:00
int(0)
string(7) "islamic"
string(12) "Europe/Minsk"
dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC
bool(false)
string(9) "gregorian"
string(3) "UTC"
==DONE==