]> granicus.if.org Git - php/commit
Added IntlTimeZone::fromDateTimeZone() and ::toDateTimeZone.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Mon, 30 Apr 2012 13:15:09 +0000 (15:15 +0200)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 17 May 2012 15:23:51 +0000 (17:23 +0200)
commit4cfd9995daf249c02f4d8a23f96288d1b2a2f4c0
tree9a05442b20a264bcb2d3f8157b585c6686d911ab
parent22f4a307481f1667bdc95f7ec7c43538427b73ab
Added IntlTimeZone::fromDateTimeZone() and ::toDateTimeZone.

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.
ext/intl/php_intl.c
ext/intl/tests/timezone_fromDateTimeZone_basic.phpt [new file with mode: 0644]
ext/intl/tests/timezone_fromDateTimeZone_error.phpt [new file with mode: 0644]
ext/intl/tests/timezone_toDateTimeZone_basic.phpt [new file with mode: 0644]
ext/intl/tests/timezone_toDateTimeZone_error.phpt [new file with mode: 0644]
ext/intl/timezone/timezone_class.cpp
ext/intl/timezone/timezone_class.h
ext/intl/timezone/timezone_methods.cpp
ext/intl/timezone/timezone_methods.h