summaryrefslogtreecommitdiff
path: root/ext/intl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/intl')
-rw-r--r--ext/intl/common/common_date.cpp20
-rw-r--r--ext/intl/converter/converter.c2
-rw-r--r--ext/intl/dateformat/dateformat_create.cpp4
-rw-r--r--ext/intl/dateformat/dateformat_parse.c6
-rw-r--r--ext/intl/grapheme/grapheme_string.c3
-rw-r--r--ext/intl/idn/idn.c60
-rw-r--r--ext/intl/intl_convert.c2
-rw-r--r--ext/intl/php_intl.c12
-rw-r--r--ext/intl/spoofchecker/spoofchecker_main.c4
-rw-r--r--ext/intl/tests/bug62915-2.phpt2
-rw-r--r--ext/intl/tests/bug75378.phpt19
-rw-r--r--ext/intl/tests/calendar_getDayOfWeekType_basic.phpt2
-rw-r--r--ext/intl/tests/calendar_getNow_basic.phpt2
-rw-r--r--ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt2
-rw-r--r--ext/intl/tests/dateformat_formatObject_calendar.phpt82
-rw-r--r--ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt14
-rw-r--r--ext/intl/tests/dateformat_formatObject_datetime.phpt68
-rw-r--r--ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt14
-rw-r--r--ext/intl/tests/dateformat_formatObject_error.phpt20
-rw-r--r--ext/intl/tests/dateformat_invalid_timezone.phpt18
-rw-r--r--ext/intl/tests/idn.phpt5
-rw-r--r--ext/intl/tests/idn_uts46_errors.phpt2
-rw-r--r--ext/intl/tests/timezone_createDefault_basic.phpt2
-rw-r--r--ext/intl/tests/timezone_getCanonicalID_variant1.phpt2
-rw-r--r--ext/intl/tests/timezone_getDisplayName_variant4.phpt2
-rw-r--r--ext/intl/timezone/timezone_class.cpp4
26 files changed, 211 insertions, 162 deletions
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp
index 26c198bc42..bd2baee776 100644
--- a/ext/intl/common/common_date.cpp
+++ b/ext/intl/common/common_date.cpp
@@ -25,13 +25,7 @@ extern "C" {
#include <ext/date/php_date.h>
}
-#ifndef INFINITY
-#define INFINITY (DBL_MAX+DBL_MAX)
-#endif
-
-#ifndef NAN
-#define NAN (INFINITY-INFINITY)
-#endif
+#include "zend_portability.h"
/* {{{ timezone_convert_datetimezone
* The timezone in DateTime and DateTimeZone is not unified. */
@@ -56,8 +50,8 @@ U_CFUNC TimeZone *timezone_convert_datetimezone(int type,
break;
case TIMELIB_ZONETYPE_OFFSET: {
int offset_mins = is_datetime
- ? -((php_date_obj*)object)->time->z
- : -(int)((php_timezone_obj*)object)->tzi.utc_offset,
+ ? ((php_date_obj*)object)->time->z / 60
+ : (int)((php_timezone_obj*)object)->tzi.utc_offset / 60,
hours = offset_mins / 60,
minutes = offset_mins - hours * 60;
minutes *= minutes > 0 ? 1 : -1;
@@ -118,7 +112,7 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
}
if (millis) {
- *millis = NAN;
+ *millis = ZEND_NAN;
}
if (tz) {
*tz = NULL;
@@ -140,7 +134,7 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
}
datetime = Z_PHPDATE_P(z);
- *millis = U_MILLIS_PER_SECOND * ((double)Z_LVAL(retval) + datetime->time->f);
+ *millis = U_MILLIS_PER_SECOND * (double)Z_LVAL(retval) + (datetime->time->us / 1000);
zval_ptr_dtor(&zfuncname);
}
@@ -176,13 +170,13 @@ U_CFUNC int intl_datetime_decompose(zval *z, double *millis, TimeZone **tz,
U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func)
{
- double rv = NAN;
+ double rv = ZEND_NAN;
zend_long lv;
int type;
char *message;
if (err && U_FAILURE(err->code)) {
- return NAN;
+ return ZEND_NAN;
}
switch (Z_TYPE_P(z)) {
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c
index 07c8cc7ad1..b893b8fd0a 100644
--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -62,7 +62,7 @@ static inline void php_converter_throw_failure(php_converter_object *objval, UEr
/* {{{ php_converter_default_callback */
static void php_converter_default_callback(zval *return_value, zval *zobj, zend_long reason, zval *error) {
ZVAL_DEREF(error);
- zval_dtor(error);
+ zval_ptr_dtor(error);
ZVAL_LONG(error, U_ZERO_ERROR);
/* Basic functionality so children can call parent::toUCallback() */
switch (reason) {
diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp
index 00a5cc593c..f08e0ed3f3 100644
--- a/ext/intl/dateformat/dateformat_create.cpp
+++ b/ext/intl/dateformat/dateformat_create.cpp
@@ -216,7 +216,9 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct )
return_value = getThis();
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) {
if (!EG(exception)) {
- zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
+ zend_string *err = intl_error_get_message(NULL);
+ zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL));
+ zend_string_release(err);
}
}
zend_restore_error_handling(&error_handling);
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c
index a8331777bb..bdf9a1e32c 100644
--- a/ext/intl/dateformat/dateformat_parse.c
+++ b/ext/intl/dateformat/dateformat_parse.c
@@ -135,7 +135,7 @@ PHP_FUNCTION(datefmt_parse)
DATE_FORMAT_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|z/!",
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|z!",
&object, IntlDateFormatter_ce_ptr, &text_to_parse, &text_len, &z_parse_pos ) == FAILURE ){
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_parse: unable to parse input params", 0 );
RETURN_FALSE;
@@ -159,7 +159,7 @@ PHP_FUNCTION(datefmt_parse)
}
internal_parse_to_timestamp( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value);
if(z_parse_pos) {
- zval_dtor(z_parse_pos);
+ zval_ptr_dtor(z_parse_pos);
ZVAL_LONG(z_parse_pos, parse_pos);
}
}
@@ -203,7 +203,7 @@ PHP_FUNCTION(datefmt_localtime)
}
internal_parse_to_localtime( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value);
if (z_parse_pos) {
- zval_dtor(z_parse_pos);
+ zval_ptr_dtor(z_parse_pos);
ZVAL_LONG(z_parse_pos, parse_pos);
}
}
diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c
index 91d5741ea1..fd03279390 100644
--- a/ext/intl/grapheme/grapheme_string.c
+++ b/ext/intl/grapheme/grapheme_string.c
@@ -804,8 +804,7 @@ PHP_FUNCTION(grapheme_extract)
} else {
ZVAL_DEREF(next);
/* initialize next */
- SEPARATE_ZVAL_NOREF(next);
- zval_dtor(next);
+ zval_ptr_dtor(next);
ZVAL_LONG(next, lstart);
}
}
diff --git a/ext/intl/idn/idn.c b/ext/intl/idn/idn.c
index cb23edd0c5..adfa81f026 100644
--- a/ext/intl/idn/idn.c
+++ b/ext/intl/idn/idn.c
@@ -111,13 +111,13 @@ enum {
};
/* like INTL_CHECK_STATUS, but as a function and varying the name of the func */
-static int php_intl_idn_check_status(UErrorCode err, const char *msg, int mode)
+static int php_intl_idn_check_status(UErrorCode err, const char *msg)
{
intl_error_set_code(NULL, err);
if (U_FAILURE(err)) {
char *buff;
spprintf(&buff, 0, "%s: %s",
- mode == INTL_IDN_TO_ASCII ? "idn_to_ascii" : "idn_to_utf8",
+ get_active_function_name(),
msg);
intl_error_set_custom_msg(NULL, buff, 1);
efree(buff);
@@ -127,14 +127,14 @@ static int php_intl_idn_check_status(UErrorCode err, const char *msg, int mode)
return SUCCESS;
}
-static inline void php_intl_bad_args(const char *msg, int mode)
+static inline void php_intl_bad_args(const char *msg)
{
- php_intl_idn_check_status(U_ILLEGAL_ARGUMENT_ERROR, msg, mode);
+ php_intl_idn_check_status(U_ILLEGAL_ARGUMENT_ERROR, msg);
}
#ifdef HAVE_46_API
static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
- const char *domain, int32_t domain_len, uint32_t option, int mode, zval *idna_info)
+ const zend_string *domain, uint32_t option, int mode, zval *idna_info)
{
UErrorCode status = U_ZERO_ERROR;
UIDNA *uts46;
@@ -145,21 +145,19 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
int buffer_used = 0;
uts46 = uidna_openUTS46(option, &status);
- if (php_intl_idn_check_status(status, "failed to open UIDNA instance",
- mode) == FAILURE) {
+ if (php_intl_idn_check_status(status, "failed to open UIDNA instance") == FAILURE) {
zend_string_free(buffer);
RETURN_FALSE;
}
if (mode == INTL_IDN_TO_ASCII) {
- len = uidna_nameToASCII_UTF8(uts46, domain, domain_len,
+ len = uidna_nameToASCII_UTF8(uts46, ZSTR_VAL(domain), ZSTR_LEN(domain),
ZSTR_VAL(buffer), buffer_capac, &info, &status);
} else {
- len = uidna_nameToUnicodeUTF8(uts46, domain, domain_len,
+ len = uidna_nameToUnicodeUTF8(uts46, ZSTR_VAL(domain), ZSTR_LEN(domain),
ZSTR_VAL(buffer), buffer_capac, &info, &status);
}
- if (len >= 255 || php_intl_idn_check_status(status, "failed to convert name",
- mode) == FAILURE) {
+ if (len >= 255 || php_intl_idn_check_status(status, "failed to convert name") == FAILURE) {
uidna_close(uts46);
zend_string_free(buffer);
RETURN_FALSE;
@@ -199,7 +197,7 @@ static void php_intl_idn_to_46(INTERNAL_FUNCTION_PARAMETERS,
#endif
static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS,
- const char *domain, int32_t domain_len, uint32_t option, int mode)
+ const zend_string *domain, uint32_t option, int mode)
{
UChar* ustring = NULL;
int ustring_len = 0;
@@ -210,7 +208,7 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS,
/* convert the string to UTF-16. */
status = U_ZERO_ERROR;
- intl_convert_utf8_to_utf16(&ustring, &ustring_len, domain, domain_len, &status);
+ intl_convert_utf8_to_utf16(&ustring, &ustring_len, ZSTR_VAL(domain), ZSTR_LEN(domain), &status);
if (U_FAILURE(status)) {
intl_error_set_code(NULL, status);
@@ -256,45 +254,47 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS,
static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
- char *domain;
- size_t domain_len;
+ zend_string *domain;
zend_long option = 0,
variant = INTL_IDN_VARIANT_2003;
zval *idna_info = NULL;
intl_error_reset(NULL);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|llz/",
- &domain, &domain_len, &option, &variant, &idna_info) == FAILURE) {
- php_intl_bad_args("bad arguments", mode);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|llz/",
+ &domain, &option, &variant, &idna_info) == FAILURE) {
+ php_intl_bad_args("bad arguments");
RETURN_NULL(); /* don't set FALSE because that's not the way it was before... */
}
#ifdef HAVE_46_API
if (variant != INTL_IDN_VARIANT_2003 && variant != INTL_IDN_VARIANT_UTS46) {
php_intl_bad_args("invalid variant, must be one of {"
- "INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46}", mode);
+ "INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46}");
RETURN_FALSE;
}
#else
if (variant != INTL_IDN_VARIANT_2003) {
php_intl_bad_args("invalid variant, PHP was compiled against "
- "an old version of ICU and only supports INTL_IDN_VARIANT_2003",
- mode);
+ "an old version of ICU and only supports INTL_IDN_VARIANT_2003");
RETURN_FALSE;
}
#endif
- if (domain_len < 1) {
- php_intl_bad_args("empty domain name", mode);
+ if (ZSTR_LEN(domain) < 1) {
+ php_intl_bad_args("empty domain name");
RETURN_FALSE;
}
- if (domain_len > INT32_MAX - 1) {
- php_intl_bad_args("domain name too large", mode);
+ if (ZSTR_LEN(domain) > INT32_MAX - 1) {
+ php_intl_bad_args("domain name too large");
RETURN_FALSE;
}
/* don't check options; it wasn't checked before */
+ if (variant == INTL_IDN_VARIANT_2003) {
+ php_error_docref(NULL, E_DEPRECATED, "INTL_IDNA_VARIANT_2003 is deprecated");
+ }
+
if (idna_info != NULL) {
if (variant == INTL_IDN_VARIANT_2003) {
php_error_docref0(NULL, E_NOTICE,
@@ -307,18 +307,16 @@ static void php_intl_idn_handoff(INTERNAL_FUNCTION_PARAMETERS, int mode)
}
if (variant == INTL_IDN_VARIANT_2003) {
- php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU,
- domain, (int32_t)domain_len, (uint32_t)option, mode);
+ php_intl_idn_to(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (uint32_t)option, mode);
}
#ifdef HAVE_46_API
else {
- php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (int32_t)domain_len,
- (uint32_t)option, mode, idna_info);
+ php_intl_idn_to_46(INTERNAL_FUNCTION_PARAM_PASSTHRU, domain, (uint32_t)option, mode, idna_info);
}
#endif
}
-/* {{{ proto int idn_to_ascii(string domain[, int options[, int variant[, array &idna_info]]])
+/* {{{ proto string idn_to_ascii(string domain[, int options[, int variant[, array &idna_info]]])
Converts an Unicode domain to ASCII representation, as defined in the IDNA RFC */
PHP_FUNCTION(idn_to_ascii)
{
@@ -327,7 +325,7 @@ PHP_FUNCTION(idn_to_ascii)
/* }}} */
-/* {{{ proto int idn_to_utf8(string domain[, int options[, int variant[, array &idna_info]]])
+/* {{{ proto string idn_to_utf8(string domain[, int options[, int variant[, array &idna_info]]])
Converts an ASCII representation of the domain to Unicode (UTF-8), as defined in the IDNA RFC */
PHP_FUNCTION(idn_to_utf8)
{
diff --git a/ext/intl/intl_convert.c b/ext/intl/intl_convert.c
index 5092b7594f..2ae43fbb96 100644
--- a/ext/intl/intl_convert.c
+++ b/ext/intl/intl_convert.c
@@ -53,7 +53,7 @@ void intl_convert_utf8_to_utf16(
UErrorCode* status )
{
UChar* dst_buf = NULL;
- uint32_t dst_len = 0;
+ int32_t dst_len = 0;
/* If *target is NULL determine required destination buffer size (pre-flighting).
* Otherwise, attempt to convert source string; if *target buffer is not large enough
diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c
index 77cb2bac3c..b97004d03f 100644
--- a/ext/intl/php_intl.c
+++ b/ext/intl/php_intl.c
@@ -1045,6 +1045,11 @@ PHP_RSHUTDOWN_FUNCTION( intl )
*/
PHP_MINFO_FUNCTION( intl )
{
+#if !UCONFIG_NO_FORMATTING
+ UErrorCode status = U_ZERO_ERROR;
+ const char *tzdata_ver = NULL;
+#endif
+
php_info_print_table_start();
php_info_print_table_header( 2, "Internationalization support", "enabled" );
php_info_print_table_row( 2, "version", INTL_MODULE_VERSION );
@@ -1052,6 +1057,13 @@ PHP_MINFO_FUNCTION( intl )
#ifdef U_ICU_DATA_VERSION
php_info_print_table_row( 2, "ICU Data version", U_ICU_DATA_VERSION );
#endif
+#if !UCONFIG_NO_FORMATTING
+ tzdata_ver = ucal_getTZDataVersion(&status);
+ if (U_ZERO_ERROR == status) {
+ php_info_print_table_row( 2, "ICU TZData version", tzdata_ver);
+ }
+#endif
+ php_info_print_table_row( 2, "ICU Unicode version", U_UNICODE_VERSION );
php_info_print_table_end();
/* For the default locale php.ini setting */
diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c
index cb26905305..5e1d75ddad 100644
--- a/ext/intl/spoofchecker/spoofchecker_main.c
+++ b/ext/intl/spoofchecker/spoofchecker_main.c
@@ -46,7 +46,7 @@ PHP_METHOD(Spoofchecker, isSuspicious)
}
if (error_code) {
- zval_dtor(error_code);
+ zval_ptr_dtor(error_code);
ZVAL_LONG(error_code, ret);
}
RETVAL_BOOL(ret != 0);
@@ -81,7 +81,7 @@ PHP_METHOD(Spoofchecker, areConfusable)
}
if (error_code) {
- zval_dtor(error_code);
+ zval_ptr_dtor(error_code);
ZVAL_LONG(error_code, ret);
}
RETVAL_BOOL(ret != 0);
diff --git a/ext/intl/tests/bug62915-2.phpt b/ext/intl/tests/bug62915-2.phpt
index bcb069cab6..8dc3bd1512 100644
--- a/ext/intl/tests/bug62915-2.phpt
+++ b/ext/intl/tests/bug62915-2.phpt
@@ -4,6 +4,8 @@ Bug #62915: cloning of several classes is defective
<?php
if (!extension_loaded('intl'))
die('skip intl extension not enabled');
+if (!class_exists('Spoofchecker'))
+ die('skip intl extension does not have spoof checker');
--FILE--
<?php
class A extends IntlDateFormatter {
diff --git a/ext/intl/tests/bug75378.phpt b/ext/intl/tests/bug75378.phpt
new file mode 100644
index 0000000000..48d9f6f7e7
--- /dev/null
+++ b/ext/intl/tests/bug75378.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #75378 ([REGRESSION] IntlDateFormatter::parse() does not change $position argument)
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip this test requires ext/intl');
+?>
+--FILE--
+<?php
+
+$formatter = new IntlDateFormatter("en-GB", IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'UTC', null, 'yyyy-MM-dd');
+$position = 0;
+$parsedDate = $formatter->parse("2017-10-12", $position);
+var_dump($position);
+$localdate = $formatter->localtime("2017-10-12 00:00:00", $position1);
+var_dump($position1);
+?>
+--EXPECT--
+int(10)
+int(10)
diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
index 324e229de5..618fcdb0d4 100644
--- a/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
+++ b/ext/intl/tests/calendar_getDayOfWeekType_basic.phpt
@@ -31,4 +31,4 @@ int(0)
int(0)
int(0)
int(1)
-==DONE==
+==DONE==
diff --git a/ext/intl/tests/calendar_getNow_basic.phpt b/ext/intl/tests/calendar_getNow_basic.phpt
index 2df112d7b2..3f1c2488b3 100644
--- a/ext/intl/tests/calendar_getNow_basic.phpt
+++ b/ext/intl/tests/calendar_getNow_basic.phpt
@@ -20,4 +20,4 @@ var_dump(abs($time * 1000 - $proc_now) < 2000);
--EXPECT--
bool(true)
bool(true)
-==DONE==
+==DONE==
diff --git a/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt b/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt
index 998e74bc01..ac437f962b 100644
--- a/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt
+++ b/ext/intl/tests/calendar_setMinimalDaysInFirstWeek_basic.phpt
@@ -23,4 +23,4 @@ bool(true)
int(6)
bool(true)
int(5)
-==DONE==
+==DONE==
diff --git a/ext/intl/tests/dateformat_formatObject_calendar.phpt b/ext/intl/tests/dateformat_formatObject_calendar.phpt
index 9365387ce6..b2b08f362d 100644
--- a/ext/intl/tests/dateformat_formatObject_calendar.phpt
+++ b/ext/intl/tests/dateformat_formatObject_calendar.phpt
@@ -1,41 +1,41 @@
---TEST--
-IntlDateFormatter::formatObject(): IntlCalendar tests
---SKIPIF--
-<?php
-if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
-<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
---FILE--
-<?php
-ini_set("intl.error_level", E_WARNING);
-ini_set("intl.default_locale", "pt_PT");
-ini_set("date.timezone", "Europe/Lisbon");
-
-$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
-echo IntlDateFormatter::formatObject($cal), "\n";
-echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
-echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
-echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
-echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
-
-$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
-echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
-
-$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
-$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
-echo IntlDateFormatter::formatObject($cal), "\n";
-echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
-
-?>
-==DONE==
-
---EXPECTF--
-01/01/2012 00:00:00
-Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental
-Jan 1, 2012 12:00:00 AM
-1/1/12 12:00:00 AM Western European %STime
-Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon)
-Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00
-06/02/1433 00:00:00
-Sunday, Safar 6, 1433 12:00:00 AM Western European %STime
-==DONE==
-
+--TEST--
+IntlDateFormatter::formatObject(): IntlCalendar tests
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", "Europe/Lisbon");
+
+$cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00'); //Europe/Lisbon
+echo IntlDateFormatter::formatObject($cal), "\n";
+echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL), "\n";
+echo IntlDateFormatter::formatObject($cal, null, "en-US"), "\n";
+echo IntlDateFormatter::formatObject($cal, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
+echo IntlDateFormatter::formatObject($cal, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
+
+$cal = IntlCalendar::fromDateTime('2012-01-01 05:00:00+03:00');
+echo datefmt_format_object($cal, IntlDateFormatter::FULL), "\n";
+
+$cal = IntlCalendar::createInstance(null,'en-US@calendar=islamic-civil');
+$cal->setTime(strtotime('2012-01-01 00:00:00')*1000.);
+echo IntlDateFormatter::formatObject($cal), "\n";
+echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n";
+
+?>
+==DONE==
+
+--EXPECTF--
+01/01/2012 00:00:00
+Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental
+Jan 1, 2012 12:00:00 AM
+1/1/12 12:00:00 AM Western European %STime
+Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon)
+Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00
+06/02/1433 00:00:00
+Sunday, Safar 6, 1433 12:00:00 AM Western European %STime
+==DONE==
+
diff --git a/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt b/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt
index d59c635a7d..688ccc31bf 100644
--- a/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt
+++ b/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt
@@ -1,10 +1,10 @@
---TEST--
-IntlDateFormatter::formatObject(): IntlCalendar tests
---SKIPIF--
-<?php
+--TEST--
+IntlDateFormatter::formatObject(): IntlCalendar tests
+--SKIPIF--
+<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
---FILE--
+--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
@@ -27,8 +27,8 @@ echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\
?>
==DONE==
-
---EXPECTF--
+
+--EXPECTF--
01/01/2012, 00:00:00
Domingo, 1 de Janeiro de 2012 às 00:00:00 Hora %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
diff --git a/ext/intl/tests/dateformat_formatObject_datetime.phpt b/ext/intl/tests/dateformat_formatObject_datetime.phpt
index 2c9e1e33be..a2cba4c76b 100644
--- a/ext/intl/tests/dateformat_formatObject_datetime.phpt
+++ b/ext/intl/tests/dateformat_formatObject_datetime.phpt
@@ -1,34 +1,34 @@
---TEST--
-IntlDateFormatter::formatObject(): DateTime tests
---SKIPIF--
-<?php
-if (!extension_loaded('intl')) die('skip intl extension not enabled') ?>
-<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
---FILE--
-<?php
-ini_set("intl.error_level", E_WARNING);
-ini_set("intl.default_locale", "pt_PT");
-ini_set("date.timezone", "Europe/Lisbon");
-
-$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
-echo IntlDateFormatter::formatObject($dt), "\n";
-echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
-echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
-echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
-echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
-
-$dt = new DateTime('2012-01-01 05:00:00+03:00');
-echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
-
-?>
-==DONE==
-
---EXPECTF--
-01/01/2012 00:00:00
-Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental
-Jan 1, 2012 12:00:00 AM
-1/1/12 12:00:00 AM Western European %STime
-Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon)
-Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00
-==DONE==
-
+--TEST--
+IntlDateFormatter::formatObject(): DateTime tests
+--SKIPIF--
+<?php
+if (!extension_loaded('intl')) die('skip intl extension not enabled') ?>
+<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') >= 0) die('skip for ICU < 50.1.2'); ?>
+--FILE--
+<?php
+ini_set("intl.error_level", E_WARNING);
+ini_set("intl.default_locale", "pt_PT");
+ini_set("date.timezone", "Europe/Lisbon");
+
+$dt = new DateTime('2012-01-01 00:00:00'); //Europe/Lisbon
+echo IntlDateFormatter::formatObject($dt), "\n";
+echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
+echo IntlDateFormatter::formatObject($dt, null, "en-US"), "\n";
+echo IntlDateFormatter::formatObject($dt, array(IntlDateFormatter::SHORT, IntlDateFormatter::FULL), "en-US"), "\n";
+echo IntlDateFormatter::formatObject($dt, 'E y-MM-d HH,mm,ss.SSS v', "en-US"), "\n";
+
+$dt = new DateTime('2012-01-01 05:00:00+03:00');
+echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
+
+?>
+==DONE==
+
+--EXPECTF--
+01/01/2012 00:00:00
+Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental
+Jan 1, 2012 12:00:00 AM
+1/1/12 12:00:00 AM Western European %STime
+Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon)
+Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00
+==DONE==
+
diff --git a/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt b/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt
index b4e59f5b7e..567a7eb849 100644
--- a/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt
+++ b/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt
@@ -1,10 +1,10 @@
---TEST--
-IntlDateFormatter::formatObject(): DateTime tests
---SKIPIF--
-<?php
+--TEST--
+IntlDateFormatter::formatObject(): DateTime tests
+--SKIPIF--
+<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '51.2') < 0 || version_compare(INTL_ICU_VERSION, '52.1') >= 0) die('skip for ICU >= 51.2 and < 52.1'); ?>
---FILE--
+--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
@@ -22,8 +22,8 @@ echo IntlDateFormatter::formatObject($dt, IntlDateFormatter::FULL), "\n";
?>
==DONE==
-
---EXPECTF--
+
+--EXPECTF--
01/01/2012, 00:00:00
Domingo, 1 de Janeiro de 2012 às 00:00:00 Hora %Sda Europa Ocidental
Jan 1, 2012, 12:00:00 AM
diff --git a/ext/intl/tests/dateformat_formatObject_error.phpt b/ext/intl/tests/dateformat_formatObject_error.phpt
index 7aaf69e54e..221602d135 100644
--- a/ext/intl/tests/dateformat_formatObject_error.phpt
+++ b/ext/intl/tests/dateformat_formatObject_error.phpt
@@ -1,10 +1,10 @@
---TEST--
-IntlDateFormatter::formatObject(): error conditions
---SKIPIF--
-<?php
-if (!extension_loaded('intl'))
- die('skip intl extension not enabled');
---FILE--
+--TEST--
+IntlDateFormatter::formatObject(): error conditions
+--SKIPIF--
+<?php
+if (!extension_loaded('intl'))
+ die('skip intl extension not enabled');
+--FILE--
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "pt_PT");
@@ -30,8 +30,8 @@ var_dump(IntlDateFormatter::formatObject($cal, "YYYY", array()));
?>
==DONE==
-
---EXPECTF--
+
+--EXPECTF--
Warning: IntlDateFormatter::formatObject() expects at least 1 parameter, 0 given in %s on line %d
bool(false)
@@ -71,4 +71,4 @@ bool(false)
Warning: IntlDateFormatter::formatObject() expects parameter 3 to be string, array given in %s on line %d
bool(false)
==DONE==
-
+
diff --git a/ext/intl/tests/dateformat_invalid_timezone.phpt b/ext/intl/tests/dateformat_invalid_timezone.phpt
new file mode 100644
index 0000000000..5b54fa89bb
--- /dev/null
+++ b/ext/intl/tests/dateformat_invalid_timezone.phpt
@@ -0,0 +1,18 @@
+--TEST--
+IntlDateFormat constructor failure
+--INI--
+date.timezone=Mars/Utopia_Planitia
+--SKIPIF--
+<?php
+extension_loaded('intl') || print 'skip';
+--FILE--
+<?php
+
+try {
+ new \IntlDateFormatter('en_US', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL);
+ echo "Wat?";
+} catch (\IntlException $e) {
+ echo $e->getMessage();
+}
+--EXPECT--
+IntlDateFormatter::__construct(): Invalid date.timezone value 'Mars/Utopia_Planitia', we selected the timezone 'UTC' for now.
diff --git a/ext/intl/tests/idn.phpt b/ext/intl/tests/idn.phpt
index fde822a560..6c00c95493 100644
--- a/ext/intl/tests/idn.phpt
+++ b/ext/intl/tests/idn.phpt
@@ -13,6 +13,9 @@ echo idn_to_ascii("t\xC3\xA4st.de")."\n";
echo urlencode(idn_to_utf8('xn--tst-qla.de'))."\n";
?>
---EXPECT--
+--EXPECTF--
+Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in %s on line %d
xn--tst-qla.de
+
+Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in %s on line %d
t%C3%A4st.de \ No newline at end of file
diff --git a/ext/intl/tests/idn_uts46_errors.phpt b/ext/intl/tests/idn_uts46_errors.phpt
index 3b1a2f0d5b..5de890ea67 100644
--- a/ext/intl/tests/idn_uts46_errors.phpt
+++ b/ext/intl/tests/idn_uts46_errors.phpt
@@ -62,6 +62,8 @@ Warning: idn_to_ascii(): idn_to_ascii: empty domain name in %s on line %d
bool(false)
fourth arg for 2003 variant (only notice raised):
+Deprecated: idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated in %s on line %d
+
Notice: idn_to_ascii(): 4 arguments were provided, but INTL_IDNA_VARIANT_2003 only takes 3 - extra argument ignored in %s on line %d
string(7) "foo.com"
with error, but no details arg:
diff --git a/ext/intl/tests/timezone_createDefault_basic.phpt b/ext/intl/tests/timezone_createDefault_basic.phpt
index 1988d3b9e5..f8e3158cec 100644
--- a/ext/intl/tests/timezone_createDefault_basic.phpt
+++ b/ext/intl/tests/timezone_createDefault_basic.phpt
@@ -28,4 +28,4 @@ IntlTimeZone Object
[rawOffset] => %i
[currentOffset] => %i
)
-==DONE==
+==DONE==
diff --git a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt
index d600792d7c..182fe15b60 100644
--- a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt
+++ b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt
@@ -20,4 +20,4 @@ string(13) "Europe/Lisbon"
bool(true)
string(0) ""
bool(false)
-==DONE==
+==DONE==
diff --git a/ext/intl/tests/timezone_getDisplayName_variant4.phpt b/ext/intl/tests/timezone_getDisplayName_variant4.phpt
index 39e28892a4..c8379d34a0 100644
--- a/ext/intl/tests/timezone_getDisplayName_variant4.phpt
+++ b/ext/intl/tests/timezone_getDisplayName_variant4.phpt
@@ -32,4 +32,4 @@ string(5) "+0000"
string(3) "GMT"
string(3) "GMT"
string(13) "Portugal Time"
-==DONE==
+==DONE==
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index f67e55ae4e..b036de81cf 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -83,8 +83,8 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
* so we must mess with DateTimeZone structure ourselves */
tzobj->initialized = 1;
tzobj->type = TIMELIB_ZONETYPE_OFFSET;
- //convert offset from milliseconds to minutes
- tzobj->tzi.utc_offset = -1 * timeZone->getRawOffset() / (60 * 1000);
+ //convert offset from milliseconds to seconds
+ tzobj->tzi.utc_offset = timeZone->getRawOffset() / 1000;
} else {
zend_string *u8str;
/* Call the constructor! */