On Mon, 02 Apr 2012 11:44:17 +0200, Derick Rethans <der...@php.net> wrote:
On Mon, 2 Apr 2012, Johannes Schlüter wrote:
Basically it is good to have those calender stuff available. I wonder
how this relates to our datelib. Can this somehow be integrated, at
least for Gregorian calender times, so one can easily convert from one
to the other etc.? Ideally we'd just have one API :-)
We could surely add functions that convert between DateTime and
IntlCalendar objects (there would be some issues on how tightly the time
zones could be integrated; see below). But to have one API is basically
near impossible given that PHP does not depend itself on ICU.
Sadly, when I looked at it last time, the ICU stuff insistent on having
a timestamp only as input to their formatting functionality :-/ We'd
need to use a few things on the ext/date side to get ICU locale
formatting into the date/time stuff.
This is not about formatting. This is about these kind of date
calculations:
* converting timestamps to dates and vice-versa (but not in a human
readable fashion, locales affect only the calendar type and minor stuff
like when the week or weekend start; you get the date fields by method
calls such as $cal->get(IntlCalendar::FIELD_HOUR_OF_DAY)).
* Adding and rolling amounts to fields.
* Calculating field differences.
* Determine weekend onsets and offsets.
The formatting and parsing of dates is done with IntlDateFormatter, which
accepts DateTime objects, though this "integration" with the date
extension could possibly be improved.
Going a bit off-topic:
I think the problem you have with datefmt_format is that the time zone is
specified through the formatter and the one of DateTime is ignored. One
could add a new function that creates a formatter with the correct time
zone extracted from DateTime, but there's still the problem that ICU
cannot use PHP's time zone objects directly, so we'd have to use the
identifiers. It could be possible to subclass ICU's TimeZone class to
create a ICU TimeZone that would wrap a DateTimeZone, but it would also
imply using the C++ API for IntlDateFormatter, which is not the case
currently.
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php