Commit Graph

14 Commits

Author SHA1 Message Date
Gustavo Lopes
dacd11ea89 Fixed cloning in ext/intl classes; master specific 2012-08-26 23:44:54 +02:00
Gustavo André dos Santos Lopes
99e48d3a57 Merge branch 'datefmt_tz_cal_interop'
* datefmt_tz_cal_interop:
  Readded accidentally removed line
  Added IntlDateFormatter::formatObject(). Refactor
  Refactored internal_get_timestamp()
  Unified zval -> UDate conversions
2012-07-22 04:22:48 +02:00
Gustavo André dos Santos Lopes
2f0775b999 Added IntlDateFormatter::formatObject(). Refactor
To better support IntlCalendar, added this function:

string IntlDateFormatter::formatObject(IntlCalendar|DateTime $obj [,
	array|int|string $format = null [, string $locale = null).

$format is either of the constants IntlDateFormatter::FULL, etc., in
which case this format applies to both the date and the time, an array
in the form array($dateFormat, $timeFormat), or a string with the
SimpleDateFormat pattern.

This uses both the Calendar type and the timezone of the passed object
to configure the formatter (a GregorianCalendar is forced for
DateTime).

Some stuff was moved around and slighlt modified to allow for more code
reuse.
2012-07-22 04:22:23 +02:00
Gustavo André dos Santos Lopes
9c5074a484 Fix undeclared intl_locale_get_default()
This was causing segfaults at least in the resourcebundle
constructor.

Also moved intl_locale_get_default() to a more central location
and fixed a constness warning in resourcebundle_ctor().
2012-06-25 10:59:58 +02:00
Gustavo André dos Santos Lopes
eb346ef0f4 DateFormat plays nice with Calendar, TimeZone
The following changes were made:

* The IntlDateFormatter constructor now accepts the usual values
  for its $timezone argument. This includes timezone identifiers,
  IntlTimeZone objects, DateTimeZone objects and NULL. An empty
  string is not accepted. An invalid time zone is no longer accepted
  (it used to use UTC in this case).
* When NULL is passed to IntlDateFormatter, the time zone specified in
  date.timezone is used instead of the ICU default.
* The IntlDateFormatter $calendar argument now accepts also an
  IntlCalendar. In this case, IntlDateFormatter::getCalendar() will
  return false.
* The time zone passed to the IntlDateFormatter is ignored if it is
  NULL and if the calendar passed is an IntlCalendar object -- in this
  case, the IntlCalendar time zone will be used instead. Otherwise,
  the time zone specified in the $timezone argument is used instead.
* Added IntlDateFormatter::getCalendarObject(), which always returns
  the IntlCalendar object that backs the DateFormat, even if a
  constant was passed to the constructor, i.e., if an IntlCalendar
  was not passed to the constructor.
* Added IntlDateFormatter::setTimeZone(). It accepts the usual values
  for time zone arguments. If NULL is passed, the time zone of the
  IntlDateFormatter WILL be overridden with the default time zone,
  even if an IntlCalendar object was passed to the constructor.
* Added IntlDateFormatter::getTimeZone(), which returns the time zone
  that's associated with the DateFormat.
* Depreacated IntlDateFormatter::setTimeZoneId() and made it an alias
  for IntlDateFormatter::setTimeZone(), as the new ::setTimeZone()
  also accepts plain identifiers, besides other types.
  IntlDateFormatter::getTimeZoneId() is not deprecated however.
* IntlDateFormatter::setCalendar() with a constant passed should now
  work correctly. This requires saving the requested locale to the
  constructor.
* Centralized the hacks required to avoid compilation disasters on
  Windows due to some headers being included inside and outside of
  extern "C" blocks.
2012-06-04 00:01:48 +02:00
Gustavo André dos Santos Lopes
72beff0d41 Added private constructor to IntlTimeZone. 2012-06-03 23:39:34 +02:00
Gustavo André dos Santos Lopes
f3802db7a0 Fixed write in constant memory.
clang did not forgive.
2012-06-03 23:39:27 +02:00
Gustavo André dos Santos Lopes
a1e97bada8 Fixed problem in IntlCalendar debug handler
*is_temp was not being set.

Also deleted a redundant assignment to *is_temp in IntlTimeZone.
2012-05-25 13:29:19 +02:00
Gustavo André dos Santos Lopes
49b1f58194 Fixed a couple of memory leaks 2012-05-17 23:17:00 +02:00
Gustavo André dos Santos Lopes
4cfd9995da 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.
2012-05-17 17:23:51 +02:00
Gustavo André dos Santos Lopes
9a35d45a5b Accept DateTimeZone where time zones are expected.
Also unified timezone handling in IntlCalendar::setTimeZone()
to that in the IntlCalendar and IntlGregorianCalendar constructors.
2012-05-17 17:23:46 +02:00
Gustavo André dos Santos Lopes
95fbae891a Compatibility with old versions of ICU (4.0+). 2012-04-01 23:28:01 +01:00
Gustavo André dos Santos Lopes
69f75bb43c Added support for new method TimeZone::getUnknown() added in ICU 49. 2012-04-01 23:28:00 +01:00
Gustavo André dos Santos Lopes
5e65205a8f Initial checkin of calendar/timezone code. 2012-04-01 23:28:00 +01:00