mirror of
https://github.com/php/php-src.git
synced 2024-10-02 15:26:06 +00:00
4cfd9995da
IntlTimeZone::fromDateTimeZone(DateTimeZone $dtz) converts from an ext/date TimeZone to an IntlTimeZone. The conversion is done by feeding the time zone name (essentially what would be given by DateTimeZone::getName()) to ICU's TimeZone::createTimeZone except if it's an offset time zone. In that case, the offset is read from the ext/date time zone object structure and an appopriate id (of the form GMT<+|-><HH:MM>) is given to ICU's TimeZone::createTimeZone. Not all ext/date time zones are recognized for ICU. For instance, WEST is not. Note that these kind of abbreviations, as far as I can tell, can only be created via ext/date DateTime, not directly through DateTimeZone's constructor. For IntlTimeZone::toDateTimeZone(), the behavior is symmetrical. We instantiate a DateTimeZone and then call its constructor if we don't have an offset time zone, otherwise we mess with its structure. If the timezone is not valid for ext/date, then we allow the exception of DateTimeZone constructor to propagate.
49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
--TEST--
|
|
IntlTimeZone::fromDateTimeZone(): argument errors
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('intl'))
|
|
die('skip intl extension not enabled');
|
|
--FILE--
|
|
<?php
|
|
ini_set("intl.error_level", E_WARNING);
|
|
|
|
var_dump(IntlTimeZone::fromDateTimeZone());
|
|
var_dump(IntlTimeZone::fromDateTimeZone(1,2));
|
|
var_dump(IntlTimeZone::fromDateTimeZone('sdfds'));
|
|
var_dump(IntlTimeZone::fromDateTimeZone(new stdclass));
|
|
$dt = new DateTime('2012-08-01 00:00:00 WEST');
|
|
var_dump(IntlTimeZone::fromDateTimeZone($dt->getTimeZone()));
|
|
|
|
var_dump(intltz_from_date_time_zone());
|
|
|
|
--EXPECTF--
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 0 given in %s on line %d
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
|
|
NULL
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone() expects exactly 1 parameter, 2 given in %s on line %d
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
|
|
NULL
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, string given in %s on line %d
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
|
|
NULL
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone() expects parameter 1 to be DateTimeZone, object given in %s on line %d
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: bad arguments in %s on line %d
|
|
NULL
|
|
|
|
Warning: IntlTimeZone::fromDateTimeZone(): intltz_from_date_time_zone: time zone id 'WEST' extracted from ext/date DateTimeZone not recognized in %s on line %d
|
|
NULL
|
|
|
|
Warning: intltz_from_date_time_zone() expects exactly 1 parameter, 0 given in %s on line %d
|
|
|
|
Warning: intltz_from_date_time_zone(): intltz_from_date_time_zone: bad arguments in %s on line %d
|
|
NULL
|