bjori Wed Oct 4 12:50:02 2006 UTC Modified files: /php-src/ext/calendar cal_unix.c Log: Update to the new parameter parsing API http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/cal_unix.c?r1=1.19&r2=1.20&diff_format=u Index: php-src/ext/calendar/cal_unix.c diff -u php-src/ext/calendar/cal_unix.c:1.19 php-src/ext/calendar/cal_unix.c:1.20 --- php-src/ext/calendar/cal_unix.c:1.19 Sun Jan 1 13:09:48 2006 +++ php-src/ext/calendar/cal_unix.c Wed Oct 4 12:50:02 2006 @@ -28,28 +28,19 @@ Convert UNIX timestamp to Julian Day */ PHP_FUNCTION(unixtojd) { - zval *timestamp; + time_t timestamp = time(NULL); long jdate; - time_t t; struct tm *ta, tmbuf; - int myargc=ZEND_NUM_ARGS(); - if ((myargc > 1) || (zend_get_parameters(ht, myargc, ×tamp) != SUCCESS)) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", ×tamp) == FAILURE) { + return; } - if(myargc==1) { - convert_to_long(timestamp); - t = Z_LVAL_P(timestamp); - } else { - t = time(NULL); - } - - if(t < 0) { + if(timestamp < 0) { RETURN_FALSE; } - ta = php_localtime_r(&t, &tmbuf); + ta = php_localtime_r(×tamp, &tmbuf); jdate = GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, ta->tm_mday); RETURN_LONG(jdate); @@ -60,17 +51,13 @@ Convert Julian Day to UNIX timestamp */ PHP_FUNCTION(jdtounix) { - zval *jday; - long uday; + long uday, jday; - if ((ZEND_NUM_ARGS()!= 1) || (zend_get_parameters(ht, 1, &jday) != SUCCESS)) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &jday) != SUCCESS) { + return; } - convert_to_long(jday); - - uday = Z_LVAL_P(jday) - 2440588 /* J.D. of 1.1.1970 */; - + uday = jday - 2440588; /* J.D. of 1.1.1970 */ if(uday<0) RETURN_FALSE; /* before beginning of unix epoch */ if(uday>24755) RETURN_FALSE; /* behind end of unix epoch */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php