Back to index

php5  5.3.10
Functions
dateformat_attr.c File Reference
#include "php_intl.h"
#include "intl_convert.h"
#include "dateformat_class.h"
#include "dateformat_attr.h"
#include <unicode/ustring.h>
#include <unicode/udat.h>
#include <unicode/ucal.h>

Go to the source code of this file.

Functions

static void internal_set_calendar (IntlDateFormatter_object *dfo, char *timezone_id, int timezone_id_len, int calendar, zval *return_value TSRMLS_DC)
 PHP_FUNCTION (datefmt_get_datetype)
 PHP_FUNCTION (datefmt_get_timetype)
 PHP_FUNCTION (datefmt_get_calendar)
 PHP_FUNCTION (datefmt_get_timezone_id)
 PHP_FUNCTION (datefmt_set_timezone_id)
 PHP_FUNCTION (datefmt_get_pattern)
 PHP_FUNCTION (datefmt_set_pattern)
 PHP_FUNCTION (datefmt_get_locale)
 PHP_FUNCTION (datefmt_is_lenient)
 PHP_FUNCTION (datefmt_set_lenient)
 PHP_FUNCTION (datefmt_set_calendar)

Function Documentation

static void internal_set_calendar ( IntlDateFormatter_object dfo,
char *  timezone_id,
int  timezone_id_len,
int  calendar,
zval *return_value  TSRMLS_DC 
) [static]

Definition at line 29 of file dateformat_attr.c.

                                                                                                                                                    {
       int         timezone_utf16_len = 0;
       UChar*      timezone_utf16  = NULL; /* timezone_id in UTF-16 */
       char*       locale = NULL;

       UCalendar*   ucal_obj = NULL;

       /* check for the validity  of value of calendar passed */
       intl_error_reset( NULL TSRMLS_CC );
       if( calendar > 1){
              intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
                     "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
              RETURN_FALSE;
       }

       /* 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_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );

       /* 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) );
       udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
       INTL_METHOD_CHECK_STATUS(dfo, "Error setting the calendar.");

       if( timezone_utf16){
              efree(timezone_utf16);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file dateformat_attr.c.

{
       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,  
                     "datefmt_get_datetype: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter datetype." );

       RETURN_LONG(dfo->date_type );
}

Here is the call graph for this function:

Definition at line 92 of file dateformat_attr.c.

{
       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,  
                     "datefmt_get_timetype: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timetype." );

       RETURN_LONG(dfo->time_type );
}

Here is the call graph for this function:

Definition at line 119 of file dateformat_attr.c.

{
       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,  
                     "datefmt_get_calendar: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter calendar." );

       RETURN_LONG(dfo->calendar);
}

Here is the call graph for this function:

Definition at line 145 of file dateformat_attr.c.

{
       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,  
                     "datefmt_get_timezone_id: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter timezone_id." );

       if( dfo->timezone_id ){
              RETURN_STRING((char*)dfo->timezone_id, TRUE );
       }else{
              RETURN_NULL();
       }
}

Here is the call graph for this function:

Definition at line 174 of file dateformat_attr.c.

{
       char*         timezone_id          = NULL;
       int           timezone_id_len      = 0;

       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 )
       {
              intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
                     "datefmt_set_timezone_id: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       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 );

       /* Set the IntlDateFormatter variable */
        if( dfo->timezone_id ){
              efree(dfo->timezone_id);
       }
       dfo->timezone_id = estrndup(timezone_id, timezone_id_len);

       RETURN_TRUE;
}

Here is the call graph for this function:

Definition at line 209 of file dateformat_attr.c.

{
       UChar  value_buf[64];
       int    length = USIZE( value_buf );
       UChar* value  = value_buf;
       zend_bool   is_pattern_localized =FALSE;

       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,  
                     "datefmt_get_pattern: unable to parse input params", 0 TSRMLS_CC );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       length = udat_toPattern(DATE_FORMAT_OBJECT(dfo), is_pattern_localized, value, length, &INTL_DATA_ERROR_CODE(dfo));
       if(INTL_DATA_ERROR_CODE(dfo) == U_BUFFER_OVERFLOW_ERROR && length >= USIZE( value_buf )) {
              ++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) );
              if(U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
                     efree(value);
                     value = value_buf;
              }
       }
       INTL_METHOD_CHECK_STATUS(dfo, "Error getting formatter pattern" );

       INTL_METHOD_RETVAL_UTF8( dfo, value, length, ( value != value_buf ) );
}

Here is the call graph for this function:

Definition at line 251 of file dateformat_attr.c.

{
       char*       value = NULL;
       int         value_len = 0;
       int         slength = 0;
       UChar*     svalue  = NULL;
       zend_bool   is_pattern_localized =FALSE;


       DATE_FORMAT_METHOD_INIT_VARS;

       /* Parse parameters. */
       if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
              &object, IntlDateFormatter_ce_ptr,  &value, &value_len ) == FAILURE )
       {
              intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,   
                     "datefmt_set_pattern: unable to parse input params", 0 TSRMLS_CC);
              RETURN_FALSE;
       }

       DATE_FORMAT_METHOD_FETCH_OBJECT;

       /* Convert given pattern to UTF-16. */
       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);

       if (svalue) {
              efree(svalue);
       }
       INTL_METHOD_CHECK_STATUS(dfo, "Error setting symbol value");

       RETURN_TRUE;
}

Here is the call graph for this function:

Definition at line 293 of file dateformat_attr.c.

{
       char *loc;
       long  loc_type =ULOC_ACTUAL_LOCALE;

       DATE_FORMAT_METHOD_INIT_VARS;

       /* Parse parameters. */
       if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l",
              &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 );

              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type,&INTL_DATA_ERROR_CODE(dfo));
       INTL_METHOD_CHECK_STATUS(dfo, "Error getting locale");
       RETURN_STRING(loc, 1);
}

Here is the call graph for this function:

Definition at line 324 of file dateformat_attr.c.

{
       
       DATE_FORMAT_METHOD_INIT_VARS;

       /* 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,
                     "datefmt_is_lenient: unable to parse input params", 0 TSRMLS_CC );

              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       RETVAL_BOOL(udat_isLenient(DATE_FORMAT_OBJECT(dfo)));
}

Here is the call graph for this function:

Definition at line 351 of file dateformat_attr.c.

{
       zend_bool isLenient  = FALSE;

       DATE_FORMAT_METHOD_INIT_VARS;

       /* Parse parameters. */
       if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob",
       &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 );
              RETURN_FALSE;
       }

       /* Fetch the object. */
       DATE_FORMAT_METHOD_FETCH_OBJECT;

       udat_setLenient(DATE_FORMAT_OBJECT(dfo), (UBool)isLenient );
}

Here is the call graph for this function:

Definition at line 378 of file dateformat_attr.c.

{
       long   calendar = 0;

       DATE_FORMAT_METHOD_INIT_VARS;

       /* Parse parameters. */
       if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
              &object, IntlDateFormatter_ce_ptr, &calendar ) == FAILURE ) {
              intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
                     "datefmt_set_calendar: unable to parse input params", 0 TSRMLS_CC);
              RETURN_FALSE;
       }

       /* check for the validity  of value of calendar passed */
       intl_error_reset( NULL TSRMLS_CC );
       if (calendar > 1) {
              intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
                     "datefmt_set_calendar: calendar value specified is out of valid range", 0 TSRMLS_CC);
              RETURN_FALSE;
       }

       DATE_FORMAT_METHOD_FETCH_OBJECT;

       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;

       RETURN_TRUE;
}

Here is the call graph for this function: