summaryrefslogtreecommitdiff
path: root/ext/intl/dateformat
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2008-09-04 00:08:17 +0000
committerStanislav Malyshev <stas@php.net>2008-09-04 00:08:17 +0000
commit95d9565902659368d14a35289843a0a79db9b61d (patch)
treecc3fafc3a2fe62e72a961f83dbc970e34ba3f9c3 /ext/intl/dateformat
parent74c83ca2097ef732e666846253275b1bfc9fdd6d (diff)
downloadphp-git-95d9565902659368d14a35289843a0a79db9b61d.tar.gz
ws cleanup
Diffstat (limited to 'ext/intl/dateformat')
-rwxr-xr-xext/intl/dateformat/dateformat.c10
-rwxr-xr-xext/intl/dateformat/dateformat_attr.c47
2 files changed, 28 insertions, 29 deletions
diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.c
index 20e9d70887..0eac9e9c7b 100755
--- a/ext/intl/dateformat/dateformat.c
+++ b/ext/intl/dateformat/dateformat.c
@@ -75,7 +75,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
zval* object;
long date_type = 0;
long time_type = 0;
- long calendar = 1;
+ long calendar = UCAL_GREGORIAN;
char* timezone_str = NULL;
int timezone_str_len = 0;
char* pattern_str = NULL;
@@ -91,7 +91,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
object = return_value;
/* Parse parameters. */
if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sll|sls",
- &locale, &locale_len, &date_type, & time_type , &timezone_str, &timezone_str_len , &calendar ,&pattern_str , &pattern_str_len ) == FAILURE )
+ &locale, &locale_len, &date_type, &time_type, &timezone_str, &timezone_str_len, &calendar,&pattern_str, &pattern_str_len ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: unable to parse input parameters", 0 TSRMLS_CC );
zval_dtor(return_value);
@@ -117,14 +117,14 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
}
if( pattern_str && pattern_str_len>0 ){
- DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE,UDAT_IGNORE, locale, timezone_utf16, timezone_utf16_len ,svalue ,slength , &INTL_DATA_ERROR_CODE(dfo));
+ DATE_FORMAT_OBJECT(dfo) = udat_open(UDAT_IGNORE, UDAT_IGNORE, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo));
} else {
- DATE_FORMAT_OBJECT(dfo) = udat_open(time_type,date_type, locale, timezone_utf16, timezone_utf16_len ,svalue ,slength , &INTL_DATA_ERROR_CODE(dfo));
+ DATE_FORMAT_OBJECT(dfo) = udat_open(time_type, date_type, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo));
}
/* Set the calendar if passed */
if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo)) && calendar) {
- ucal_obj = ucal_open( timezone_utf16 , timezone_utf16_len , locale , calendar , &INTL_DATA_ERROR_CODE(dfo) );
+ ucal_obj = ucal_open( timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) );
if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
}
diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.c
index 717b44b1d6..51012896ed 100755
--- a/ext/intl/dateformat/dateformat_attr.c
+++ b/ext/intl/dateformat/dateformat_attr.c
@@ -26,11 +26,10 @@
#include <unicode/udat.h>
#include <unicode/ucal.h>
-static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_id , int timezone_id_len , int calendar ,zval* return_value TSRMLS_DC){
+static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_id, int timezone_id_len, int calendar, zval* return_value TSRMLS_DC){
int timezone_utf16_len = 0;
UChar* timezone_utf16 = NULL; /* timezone_id in UTF-16 */
char* locale = NULL;
- int locale_type =ULOC_ACTUAL_LOCALE;
UCalendar* ucal_obj = NULL;
@@ -43,14 +42,14 @@ static void internal_set_calendar(IntlDateFormatter_object *dfo, char* timezone_
}
/* Convert timezone to UTF-16. */
- intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len , &INTL_DATA_ERROR_CODE(dfo));
+ intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_id, timezone_id_len, &INTL_DATA_ERROR_CODE(dfo));
INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
- /* Get the lcoale for the dateformatter */
- locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), locale_type ,&INTL_DATA_ERROR_CODE(dfo));
+ /* Get the locale for the dateformatter */
+ locale = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(dfo));
/* Set the calendar if passed */
- ucal_obj = ucal_open( timezone_utf16 , timezone_utf16_len , locale , calendar , &INTL_DATA_ERROR_CODE(dfo) );
+ ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) );
udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar.");
@@ -71,7 +70,7 @@ PHP_FUNCTION( datefmt_get_datetype )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
- intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_get_datetype: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
@@ -97,7 +96,7 @@ PHP_FUNCTION( datefmt_get_timetype )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
- intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_get_timetype: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
@@ -124,7 +123,7 @@ PHP_FUNCTION( datefmt_get_calendar )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
- intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
@@ -134,7 +133,7 @@ PHP_FUNCTION( datefmt_get_calendar )
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter calendar." );
- RETURN_LONG(dfo->calendar );
+ RETURN_LONG(dfo->calendar);
}
/* }}} */
@@ -150,7 +149,7 @@ PHP_FUNCTION( datefmt_get_timezone_id )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, IntlDateFormatter_ce_ptr ) == FAILURE )
{
- intl_error_set( NULL , U_ILLEGAL_ARGUMENT_ERROR,
+ intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_get_timezone_id: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
@@ -161,7 +160,7 @@ PHP_FUNCTION( datefmt_get_timezone_id )
INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timezone_id." );
if( dfo->timezone_id ){
- RETURN_STRING((char*)dfo->timezone_id ,TRUE );
+ RETURN_STRING((char*)dfo->timezone_id, TRUE );
}else{
RETURN_NULL();
}
@@ -169,7 +168,7 @@ PHP_FUNCTION( datefmt_get_timezone_id )
/* {{{ proto boolean IntlDateFormatter::setTimeZoneId( $timezone_id)
* Set formatter timezone_id. }}} */
-/* {{{ proto boolean datefmt_set_timezone_id( IntlDateFormatter $mf ,$timezone_id)
+/* {{{ proto boolean datefmt_set_timezone_id( IntlDateFormatter $mf,$timezone_id)
* Set formatter timezone_id.
*/
PHP_FUNCTION( datefmt_set_timezone_id )
@@ -180,7 +179,7 @@ PHP_FUNCTION( datefmt_set_timezone_id )
DATE_FORMAT_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr ,&timezone_id , &timezone_id_len) == FAILURE )
+ if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, IntlDateFormatter_ce_ptr,&timezone_id, &timezone_id_len) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC );
@@ -191,13 +190,13 @@ PHP_FUNCTION( datefmt_set_timezone_id )
DATE_FORMAT_METHOD_FETCH_OBJECT;
/* set the timezone for the calendar */
- internal_set_calendar( dfo , timezone_id , timezone_id_len , dfo->calendar ,return_value TSRMLS_CC );
+ internal_set_calendar( dfo, timezone_id, timezone_id_len, dfo->calendar, return_value TSRMLS_CC );
/* Set the IntlDateFormatter variable */
if( dfo->timezone_id ){
efree(dfo->timezone_id);
}
- dfo->timezone_id = estrndup(timezone_id , timezone_id_len);
+ dfo->timezone_id = estrndup(timezone_id, timezone_id_len);
RETURN_TRUE;
}
@@ -232,7 +231,7 @@ PHP_FUNCTION( datefmt_get_pattern )
++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */
INTL_DATA_ERROR_CODE(dfo) = U_ZERO_ERROR;
value = eumalloc(length);
- length = udat_toPattern(DATE_FORMAT_OBJECT(dfo), is_pattern_localized , value, length, &INTL_DATA_ERROR_CODE(dfo) );
+ length = udat_toPattern(DATE_FORMAT_OBJECT(dfo), is_pattern_localized, value, length, &INTL_DATA_ERROR_CODE(dfo) );
if(U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
efree(value);
value = value_buf;
@@ -275,7 +274,7 @@ PHP_FUNCTION( datefmt_set_pattern )
intl_convert_utf8_to_utf16(&svalue, &slength, value, value_len, &INTL_DATA_ERROR_CODE(dfo));
INTL_METHOD_CHECK_STATUS(dfo, "Error converting pattern to UTF-16" );
- udat_applyPattern(DATE_FORMAT_OBJECT(dfo), (UBool)is_pattern_localized , svalue, slength);
+ udat_applyPattern(DATE_FORMAT_OBJECT(dfo), (UBool)is_pattern_localized, svalue, slength);
efree(svalue);
INTL_METHOD_CHECK_STATUS(dfo, "Error setting symbol value");
@@ -298,7 +297,7 @@ PHP_FUNCTION( datefmt_get_locale )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l",
- &object, IntlDateFormatter_ce_ptr ,&loc_type) == FAILURE )
+ &object, IntlDateFormatter_ce_ptr,&loc_type) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_get_locale: unable to parse input params", 0 TSRMLS_CC );
@@ -309,7 +308,7 @@ PHP_FUNCTION( datefmt_get_locale )
/* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
- loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type ,&INTL_DATA_ERROR_CODE(dfo));
+ loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type,&INTL_DATA_ERROR_CODE(dfo));
RETURN_STRING(loc, 1);
}
/* }}} */
@@ -354,7 +353,7 @@ PHP_FUNCTION( datefmt_set_lenient )
/* Parse parameters. */
if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob",
- &object, IntlDateFormatter_ce_ptr ,&isLenient ) == FAILURE )
+ &object, IntlDateFormatter_ce_ptr,&isLenient ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"datefmt_set_lenient: unable to parse input params", 0 TSRMLS_CC );
@@ -364,7 +363,7 @@ PHP_FUNCTION( datefmt_set_lenient )
/* Fetch the object. */
DATE_FORMAT_METHOD_FETCH_OBJECT;
- udat_setLenient(DATE_FORMAT_OBJECT(dfo) , (UBool)isLenient );
+ udat_setLenient(DATE_FORMAT_OBJECT(dfo), (UBool)isLenient );
}
/* }}} */
@@ -397,10 +396,10 @@ PHP_FUNCTION( datefmt_set_calendar )
DATE_FORMAT_METHOD_FETCH_OBJECT;
- internal_set_calendar( dfo , dfo->timezone_id , strlen(dfo->timezone_id) , calendar ,return_value TSRMLS_CC );
+ internal_set_calendar( dfo, dfo->timezone_id, strlen(dfo->timezone_id), calendar, return_value TSRMLS_CC );
/* Set the calendar value in the IntlDateFormatter object */
- dfo->calendar = calendar ;
+ dfo->calendar = calendar;
RETURN_TRUE;
}