cvs: /php3/functions php3_mcal.c php3_mcal.h

From: Date: Tue, 07 Sep 1999 14:51:04 +0000
Subject: cvs: /php3/functions php3_mcal.c php3_mcal.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-10662@lists.php.net to get a copy of this message
musone Tue Sep 7 10:51:04 1999 EDT Modified files: /php3/functions php3_mcal.c php3_mcal.h Log: more convenience functions Index: php3/functions/php3_mcal.c diff -u php3/functions/php3_mcal.c:1.8 php3/functions/php3_mcal.c:1.9 --- php3/functions/php3_mcal.c:1.8 Thu Sep 2 23:18:08 1999 +++ php3/functions/php3_mcal.c Tue Sep 7 10:51:03 1999 @@ -102,6 +102,10 @@ {"mcal_event_set_start",php3_mcal_event_add_start,NULL}, {"mcal_event_set_alarm",php3_mcal_event_add_alarm,NULL}, {"mcal_event_set_class",php3_mcal_event_add_class,NULL}, + {"mcal_is_leap_year",php3_mcal_is_leap_year,NULL}, + {"mcal_days_in_month",php3_mcal_days_in_month,NULL}, + {"mcal_date_valid",php3_mcal_date_valid,NULL}, + {"mcal_time_valid",php3_mcal_time_valid,NULL}, {NULL, NULL, NULL} }; @@ -469,6 +473,7 @@ my_cal_list=g_cal_list; while(my_cal_list != NULL) { + php3_printf("linked list value: %d<br>",my_cal_list->uid); add_next_index_long(return_value,my_cal_list->uid); my_cal_list=my_cal_list->next; free(g_cal_list); @@ -1251,13 +1256,142 @@ +void php3_mcal_is_leap_year(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *year; + int ind, ind_type; + unsigned long i; + char *t; + int mcal_folders=0; + unsigned int msgno; + pils *mcal_le_struct; + pval *pvalue,*temppvalue; + cal_list_t *my_cal_list; + int myargc; + unsigned long uid; + CALEVENT *myevent; + myargc=ARG_COUNT(ht); + if (myargc !=1 || getParameters(ht,myargc,&year) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(year); + if(isleapyear(year->value.lval)) + { + RETURN_TRUE; + } + else + { + RETURN_FALSE; + } +} + +void php3_mcal_days_in_month(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *month,*leap; + int ind, ind_type; + unsigned long i; + char *t; + int mcal_folders=0; + unsigned int msgno; + pils *mcal_le_struct; + pval *pvalue,*temppvalue; + cal_list_t *my_cal_list; + int myargc; + unsigned long uid; + CALEVENT *myevent; + myargc=ARG_COUNT(ht); + if (myargc !=2 || getParameters(ht,myargc,&month,&leap) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(month); + convert_to_long(leap); + convert_to_boolean_long(leap); + RETURN_LONG(daysinmonth(month->value.lval,leap->value.lval)); +} + +void php3_date_valid(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *year,*month,*day; + int ind, ind_type; + unsigned long i; + char *t; + int mcal_folders=0; + unsigned int msgno; + pils *mcal_le_struct; + pval *pvalue,*temppvalue; + cal_list_t *my_cal_list; + int myargc; + unsigned long uid; + CALEVENT *myevent; + 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_TRUE; + } + else + { + RETURN_FALSE; + } +} + +void php3_time_valid(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *hour,*min,*sec; + int ind, ind_type; + unsigned long i; + char *t; + int mcal_folders=0; + unsigned int msgno; + pils *mcal_le_struct; + pval *pvalue,*temppvalue; + cal_list_t *my_cal_list; + int myargc; + unsigned long uid; + CALEVENT *myevent; + myargc=ARG_COUNT(ht); + if (myargc !=3 || getParameters(ht,myargc,&hour,&min,&sec) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); + if(datevalid(hour->value.lval,min->value.lval,sec->value.lval)) + { + RETURN_TRUE; + } + else + { + RETURN_FALSE; + } +} + + + + +/* returns <0, 0, >0 if a<b, a==b, a>b respectively */ +/*int dt_compare(const datetime_t *a, const datetime_t *b); */ + +/* returns the day-of-year of <dt> */ +/* int dt_dayofyear(const datetime_t *dt); */ + +/* returns the day-of-week of <dt> */ +/* int dt_dayofweek(const datetime_t *dt); */ + + + + /* Interfaces to callbacks */ void cc_searched (unsigned long cal_uid) { - if(g_cal_list==NULL) { g_cal_list=malloc(sizeof(struct cal_list)); Index: php3/functions/php3_mcal.h diff -u php3/functions/php3_mcal.h:1.3 php3/functions/php3_mcal.h:1.4 --- php3/functions/php3_mcal.h:1.3 Thu Sep 2 17:09:40 1999 +++ php3/functions/php3_mcal.h Tue Sep 7 10:51:03 1999 @@ -1,4 +1,4 @@ -/* $Id: php3_mcal.h,v 1.3 1999/09/02 21:09:40 musone Exp $ */ +/* $Id: php3_mcal.h,v 1.4 1999/09/07 14:51:03 musone Exp $ */ #ifndef _INCLUDED_MCAL_H #define _INCLUDED_MCAL_H @@ -48,6 +48,10 @@ void php3_mcal_event_add_start(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_event_add_alarm(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_event_add_class(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_is_leap_year(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_days_in_month(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_date_valid(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_time_valid(INTERNAL_FUNCTION_PARAMETERS);

« previous php.dev (#10662) next »