summaryrefslogtreecommitdiff
path: root/ext/intl/timezone
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-07-22 04:22:48 +0200
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-07-22 04:22:48 +0200
commit99e48d3a5751b486fdc49a3409edd509faa3b27c (patch)
tree911f0481885ad0039d09b9d69fd5c6138776ae13 /ext/intl/timezone
parent11a5afec22e62af1555ceedc41460b96f8c06ed5 (diff)
parent2498c90c71980168b5b9ac2fa006340b9460b1f2 (diff)
downloadphp-git-99e48d3a5751b486fdc49a3409edd509faa3b27c.tar.gz
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
Diffstat (limited to 'ext/intl/timezone')
-rw-r--r--ext/intl/timezone/timezone_class.cpp75
-rw-r--r--ext/intl/timezone/timezone_class.h1
-rw-r--r--ext/intl/timezone/timezone_methods.cpp3
3 files changed, 5 insertions, 74 deletions
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index 6e62c34f6d..27cf41a4cf 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -25,6 +25,8 @@
#include <unicode/calendar.h>
#include "../intl_convertcpp.h"
+#include "../common/common_date.h"
+
extern "C" {
#include "../intl_convert.h"
#define USE_TIMEZONE_POINTER 1
@@ -54,79 +56,6 @@ U_CFUNC void timezone_object_construct(const TimeZone *zone, zval *object, int o
}
/* }}} */
-/* {{{ timezone_convert_datetimezone
- * The timezone in DateTime and DateTimeZone is not unified. */
-U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
- void *object,
- int is_datetime,
- intl_error *outside_error,
- const char *func TSRMLS_DC)
-{
- char *id = NULL,
- offset_id[] = "GMT+00:00";
- int id_len = 0;
- char *message;
- TimeZone *timeZone;
-
- switch (type) {
- case TIMELIB_ZONETYPE_ID:
- id = is_datetime
- ? ((php_date_obj*)object)->time->tz_info->name
- : ((php_timezone_obj*)object)->tzi.tz->name;
- id_len = strlen(id);
- break;
- case TIMELIB_ZONETYPE_OFFSET: {
- int offset_mins = is_datetime
- ? -((php_date_obj*)object)->time->z
- : -(int)((php_timezone_obj*)object)->tzi.utc_offset,
- hours = offset_mins / 60,
- minutes = offset_mins - hours * 60;
- minutes *= minutes > 0 ? 1 : -1;
-
- if (offset_mins <= -24 * 60 || offset_mins >= 24 * 60) {
- spprintf(&message, 0, "%s: object has an time zone offset "
- "that's too large", func);
- intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
- message, 1 TSRMLS_CC);
- efree(message);
- return NULL;
- }
-
- id = offset_id;
- id_len = slprintf(id, sizeof(offset_id), "GMT%+03d:%02d",
- hours, minutes);
- break;
- }
- case TIMELIB_ZONETYPE_ABBR:
- id = is_datetime
- ? ((php_date_obj*)object)->time->tz_abbr
- : ((php_timezone_obj*)object)->tzi.z.abbr;
- id_len = strlen(id);
- break;
- }
-
- UnicodeString s = UnicodeString(id, id_len, US_INV);
- timeZone = TimeZone::createTimeZone(s);
-#if U_ICU_VERSION_MAJOR_NUM >= 49
- if (*timeZone == TimeZone::getUnknown()) {
-#else
- UnicodeString resultingId;
- timeZone->getID(resultingId);
- if (resultingId == UnicodeString("Etc/Unknown", -1, US_INV)
- || resultingId == UnicodeString("GMT", -1, US_INV)) {
-#endif
- spprintf(&message, 0, "%s: time zone id '%s' "
- "extracted from ext/date DateTimeZone not recognized", func, id);
- intl_errors_set(outside_error, U_ILLEGAL_ARGUMENT_ERROR,
- message, 1 TSRMLS_CC);
- efree(message);
- delete timeZone;
- return NULL;
- }
- return timeZone;
-}
-/* }}} */
-
/* {{{ timezone_convert_to_datetimezone
* Convert from TimeZone to DateTimeZone object */
U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
diff --git a/ext/intl/timezone/timezone_class.h b/ext/intl/timezone/timezone_class.h
index 0d3c0edde4..a638f6dbf4 100644
--- a/ext/intl/timezone/timezone_class.h
+++ b/ext/intl/timezone/timezone_class.h
@@ -59,7 +59,6 @@ typedef struct {
RETURN_FALSE; \
}
-TimeZone *timezone_convert_datetimezone(int type, void *object, int is_datetime, intl_error *outside_error, const char *func TSRMLS_DC);
zval *timezone_convert_to_datetimezone(const TimeZone *timeZone, intl_error *outside_error, const char *func TSRMLS_DC);
TimeZone *timezone_process_timezone_argument(zval **zv_timezone, intl_error *error, const char *func TSRMLS_DC);
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index caf5dcdedc..9ca6b44c89 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -24,6 +24,9 @@
#include <unicode/timezone.h>
#include <unicode/ustring.h>
#include "intl_convertcpp.h"
+
+#include "../common/common_date.h"
+
extern "C" {
#include "../php_intl.h"
#define USE_TIMEZONE_POINTER 1