cvs: pecl /intl/dateformat dateformat_format.c dateformat_parse.c
| From: | Kirti Velankar | Date: | Thu, 03 Apr 2008 20:58:15 +0000 |
| Subject: | cvs: pecl /intl/dateformat dateformat_format.c dateformat_parse.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-10299@lists.php.net to get a copy of this message | ||
kirtig Thu Apr 3 20:58:15 2008 UTC
Modified files:
/pecl/intl/dateformat dateformat_format.c dateformat_parse.c
Log:
Fixed localtime
http://cvs.php.net/viewvc.cgi/pecl/intl/dateformat/dateformat_format.c?r1=1.5&r2=1.6&diff_format=u
Index: pecl/intl/dateformat/dateformat_format.c
diff -u pecl/intl/dateformat/dateformat_format.c:1.5 pecl/intl/dateformat/dateformat_format.c:1.6
--- pecl/intl/dateformat/dateformat_format.c:1.5 Wed Apr 2 13:32:18 2008
+++ pecl/intl/dateformat/dateformat_format.c Thu Apr 3 20:58:15 2008
@@ -90,6 +90,7 @@
//Fetch values from the incoming array
year = internal_get_arr_ele( mfo , hash_arr , CALENDAR_YEAR TSRMLS_CC) + 1900; //tm_year is years
since 1900
+ //Month in ICU and PHP starts from January =0
month = internal_get_arr_ele( mfo , hash_arr , CALENDAR_MON TSRMLS_CC);
hour = internal_get_arr_ele( mfo , hash_arr , CALENDAR_HOUR TSRMLS_CC);
minute = internal_get_arr_ele( mfo , hash_arr , CALENDAR_MIN TSRMLS_CC);
@@ -100,14 +101,14 @@
//For the ucal_setDateTime() function , this is the 'date' value
mday = internal_get_arr_ele( mfo , hash_arr , CALENDAR_MDAY TSRMLS_CC);
- //printf("\n year= %ld , month = %ld , hour = %ld , minute = %ld , second = %ld \n" ,
year, month , hour , minute , second);
- //printf("\n wday= %ld , yday = %ld , mday = %ld , isInDST = %ld , \n" , wday , yday ,
mday , isInDST );
//set the incoming values for the calendar
ucal_setDateTime( pcal, year, month , mday , hour , minute , second ,
&INTL_DATA_ERROR_CODE(mfo));
if( INTL_DATA_ERROR_CODE(mfo) != U_ZERO_ERROR){
return;
}
- ucal_set( pcal, UCAL_DAY_OF_WEEK , wday);
+ //ICU UCAL_DAY_OF_WEEK starts from SUNDAY=1 thru SATURDAY=7
+ //whereas PHP localtime has tm_wday SUNDAY=0 thru SATURDAY=6
+ ucal_set( pcal, UCAL_DAY_OF_WEEK , (wday+1));
ucal_set( pcal, UCAL_DAY_OF_YEAR , yday);
//TO DO :How to set the isInDST field?Is it required to set
http://cvs.php.net/viewvc.cgi/pecl/intl/dateformat/dateformat_parse.c?r1=1.7&r2=1.8&diff_format=u
Index: pecl/intl/dateformat/dateformat_parse.c
diff -u pecl/intl/dateformat/dateformat_parse.c:1.7 pecl/intl/dateformat/dateformat_parse.c:1.8
--- pecl/intl/dateformat/dateformat_parse.c:1.7 Wed Apr 2 13:32:18 2008
+++ pecl/intl/dateformat/dateformat_parse.c Thu Apr 3 20:58:15 2008
@@ -63,9 +63,13 @@
static void add_to_localtime_arr( DateFormatter_object *mfo, zval* return_value ,UCalendar
parsed_calendar , long calendar_field , char* key_name TSRMLS_DC){
long calendar_field_val = ucal_get( parsed_calendar , calendar_field ,
&INTL_DATA_ERROR_CODE(mfo));
INTL_METHOD_CHECK_STATUS( mfo, "Date parsing - localtime failed : could not get a field from
calendar" );
+
if( strcmp(key_name , CALENDAR_YEAR )==0 ){
//since tm_year is years from 1900
add_assoc_long( return_value, key_name ,( calendar_field_val-1900) );
+ }else if( strcmp(key_name , CALENDAR_WDAY )==0 ){
+ //since tm_wday starts from 0 whereas ICU WDAY start from 1
+ add_assoc_long( return_value, key_name ,( calendar_field_val-1) );
}else{
add_assoc_long( return_value, key_name , calendar_field_val );
}