From: Chuck Hagenbuch Date: Sat, 11 Mar 2000 02:15:14 +0000 (+0000) Subject: Add mcal_week_of_year(), submitted by jtaskine@hit.fi. X-Git-Tag: PHP-4.0-RC1~190 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f42a770f65f83b89106ebc0a3f4b16bd3bc8e553;p=php Add mcal_week_of_year(), submitted by jtaskine@hit.fi. --- diff --git a/ext/mcal/php_mcal.c b/ext/mcal/php_mcal.c index d266e8ed50..e49bf7fb02 100644 --- a/ext/mcal/php_mcal.c +++ b/ext/mcal/php_mcal.c @@ -107,6 +107,7 @@ function_entry mcal_functions[] = { PHP_FE(mcal_time_valid,NULL) PHP_FE(mcal_day_of_week,NULL) PHP_FE(mcal_day_of_year,NULL) + PHP_FE(mcal_week_of_year,NULL) PHP_FE(mcal_date_compare,NULL) PHP_FE(mcal_event_init,NULL) PHP_FE(mcal_next_recurrence,NULL) @@ -1255,6 +1256,31 @@ PHP_FUNCTION(mcal_day_of_year) } /* }}} */ +/* {{{ proto int mcal_week_of_year(int year, int month, int day) + Returns the week number of the given date */ +PHP_FUNCTION(mcal_week_of_year) +{ + pval *year, *month, *day; + int myargc; + + myargc = ARG_COUNT(ht); + if (myargc != 3 || getParameters(ht,myargc,&year,&month,&day) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + + if (datevalid(year->value.lval,month->value.lval,day->value.lval)) { + RETURN_LONG(dt_weekofyear(day->value.lval,month->value.lval,year->value.lval)); + } + else { + RETURN_FALSE; + } +} +/* }}} */ + /* {{{ proto int mcal_day_of_week(int ayear, int amonth, int aday, int byear, int bmonth, int bday) Returns <0, 0, >0 if ab respectively */ PHP_FUNCTION(mcal_date_compare) diff --git a/ext/mcal/php_mcal.h b/ext/mcal/php_mcal.h index 153528095a..b17769d62c 100644 --- a/ext/mcal/php_mcal.h +++ b/ext/mcal/php_mcal.h @@ -65,6 +65,7 @@ PHP_FUNCTION(mcal_date_valid); PHP_FUNCTION(mcal_time_valid); PHP_FUNCTION(mcal_day_of_week); PHP_FUNCTION(mcal_day_of_year); +PHP_FUNCTION(mcal_week_of_year); PHP_FUNCTION(mcal_date_compare); PHP_FUNCTION(mcal_event_init); PHP_FUNCTION(mcal_next_recurrence);