From: Hannes Magnusson Date: Wed, 4 Oct 2006 12:50:02 +0000 (+0000) Subject: Update to the new parameter parsing API X-Git-Tag: RELEASE_1_0_0RC1~1428 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3a3c1a3a3ea4b13a8b41c8408efef643ffa8b191;p=php Update to the new parameter parsing API --- diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index b4d920add3..9a619c7bda 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -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 @@ PHP_FUNCTION(unixtojd) 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 */