]> granicus.if.org Git - php/commitdiff
Add mcal_week_of_year(), submitted by jtaskine@hit.fi.
authorChuck Hagenbuch <chagenbu@php.net>
Sat, 11 Mar 2000 02:15:14 +0000 (02:15 +0000)
committerChuck Hagenbuch <chagenbu@php.net>
Sat, 11 Mar 2000 02:15:14 +0000 (02:15 +0000)
ext/mcal/php_mcal.c
ext/mcal/php_mcal.h

index d266e8ed5013333f952b26d25fbbf6037d25b825..e49bf7fb02186574b02da77d8afe1abd88be65ee 100644 (file)
@@ -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 a<b, a==b, a>b respectively */
 PHP_FUNCTION(mcal_date_compare)
index 153528095a1cfd61036d0a5d10a08000bbd38cb1..b17769d62cd711f59cd7b96de4d6eb8ed6e5fe59 100644 (file)
@@ -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);