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

From: Date: Tue, 14 Sep 1999 18:15:18 +0000
Subject: cvs: /php3/functions php3_mcal.c php3_mcal.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-10910@lists.php.net to get a copy of this message
musone Tue Sep 14 14:15:18 1999 EDT Modified files: /php3/functions php3_mcal.c php3_mcal.h Log: recurrence end dats are just dates, not dates and times. Also added two convenience functions for setting event to current date/time Index: php3/functions/php3_mcal.c diff -u php3/functions/php3_mcal.c:1.25 php3/functions/php3_mcal.c:1.26 --- php3/functions/php3_mcal.c:1.25 Mon Sep 13 11:03:12 1999 +++ php3/functions/php3_mcal.c Tue Sep 14 14:15:17 1999 @@ -120,6 +120,8 @@ PHP_FE(mcal_event_set_recur_monthly_mday,NULL) PHP_FE(mcal_event_set_recur_monthly_wday,NULL) PHP_FE(mcal_event_set_recur_yearly,NULL) +PHP_FE(mcal_event_set_end_now,NULL) +PHP_FE(mcal_event_set_start_now,NULL) PHP_FE(mcal_fetch_current_stream_event,NULL) {NULL, NULL, NULL} }; @@ -514,12 +516,6 @@ add_property_long(&recurend,"month",event->recur_enddate.mon); add_property_long(&recurend,"mday",event->recur_enddate.mday); } - if(event->recur_enddate.has_time) - { - add_property_long(&recurend,"hour",event->recur_enddate.hour); - add_property_long(&recurend,"min",event->recur_enddate.min); - add_property_long(&recurend,"sec",event->recur_enddate.sec); - } add_assoc_object(mypvalue, "recur_enddate",recurend); add_property_long(mypvalue,"recur_data",event->recur_data.weekly_wday); } @@ -1086,6 +1082,74 @@ } /* }}} */ +/* {{{ proto int mcal_event_set_now(int stream_id) + Set a streams global event start date to the current date/time */ +void php3_mcal_event_set_start_now(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *streamind; + int ind, ind_type; + pils *mcal_le_struct; + int myargc; + myargc=ARG_COUNT(ht); + if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(streamind); + + ind = streamind->value.lval; + + mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); + + if (!mcal_le_struct ) { + php3_error(E_WARNING, "Unable to find stream pointer"); + RETURN_FALSE; + } + if(dt_now(&mcal_le_struct->event->start)) + { + RETURN_TRUE; + } + else + { + RETURN_FALSE; + } +} + /* }}} */ + +/* {{{ proto int mcal_event_set_now(int stream_id) + Set a streams global event end date to the current date/time */ +void php3_mcal_event_set_end_now(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *streamind; + int ind, ind_type; + pils *mcal_le_struct; + int myargc; + myargc=ARG_COUNT(ht); + if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(streamind); + + ind = streamind->value.lval; + + mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); + + if (!mcal_le_struct ) { + php3_error(E_WARNING, "Unable to find stream pointer"); + RETURN_FALSE; + } + if(dt_now(&mcal_le_struct->event->end)) + { + RETURN_TRUE; + } + else + { + RETURN_FALSE; + } +} + /* }}} */ + void php3_event_init(struct php3_mcal_le_struct *mystruct) { calevent_free(mystruct->event); @@ -1368,17 +1432,17 @@ -/* {{{ proto string mcal_event_set_recur_daily(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval +/* {{{ proto string mcal_event_set_recur_daily(int stream_id,int year,int month,int day,int interval create a daily recurrence */ void php3_mcal_event_set_recur_daily(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; + pval *streamind,*year,*month,*day,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { + if (myargc !=5 || getParameters(ht,myargc,&streamind,&year,&month,&day,&interval) == FAILURE) { WRONG_PARAM_COUNT; } @@ -1386,9 +1450,6 @@ convert_to_long(year); convert_to_long(month); convert_to_long(day); - convert_to_long(hour); - convert_to_long(min); - convert_to_long(sec); convert_to_long(interval); ind = streamind->value.lval; @@ -1400,24 +1461,23 @@ RETURN_FALSE; } dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); - dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_daily(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_weekly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval, int weekdays) +/* {{{ proto string mcal_event_set_recur_weekly(int stream_id,int year,int month,int day,int interval, int weekdays) create a weekly recurrence */ void php3_mcal_event_set_recur_weekly(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval,*weekdays; + pval *streamind,*year,*month,*day,*interval,*weekdays; int ind, ind_type; pils *mcal_le_struct; int myargc; datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=4 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval,&weekdays) == FAILURE) { + if (myargc !=6 || getParameters(ht,myargc,&streamind,&year,&month,&day,&interval,&weekdays) == FAILURE) { WRONG_PARAM_COUNT; } @@ -1425,9 +1485,6 @@ convert_to_long(year); convert_to_long(month); convert_to_long(day); - convert_to_long(hour); - convert_to_long(min); - convert_to_long(sec); convert_to_long(interval); convert_to_long(weekdays); ind = streamind->value.lval; @@ -1439,24 +1496,23 @@ RETURN_FALSE; } dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); - dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_weekly(mcal_le_struct->event, &endtime, interval->value.lval,weekdays->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) +/* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id,int year,int month,int day,int interval) create a monthly by day recurrence */ void php3_mcal_event_set_recur_monthly_mday(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; + pval *streamind,*year,*month,*day,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { + if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&interval) == FAILURE) { WRONG_PARAM_COUNT; } @@ -1464,9 +1520,6 @@ convert_to_long(year); convert_to_long(month); convert_to_long(day); - convert_to_long(hour); - convert_to_long(min); - convert_to_long(sec); convert_to_long(interval); ind = streamind->value.lval; @@ -1478,24 +1531,23 @@ RETURN_FALSE; } dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); - dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_monthly_mday(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) +/* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id,int year,int month,int day,int interval) create a monthy by week recurrence */ void php3_mcal_event_set_recur_monthly_wday(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; + pval *streamind,*year,*month,*day,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { + if (myargc !=5 || getParameters(ht,myargc,&streamind,&year,&month,&day,&interval) == FAILURE) { WRONG_PARAM_COUNT; } @@ -1503,9 +1555,6 @@ convert_to_long(year); convert_to_long(month); convert_to_long(day); - convert_to_long(hour); - convert_to_long(min); - convert_to_long(sec); convert_to_long(interval); ind = streamind->value.lval; @@ -1517,24 +1566,23 @@ RETURN_FALSE; } dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); - dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_monthly_wday(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_yearly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) +/* {{{ proto string mcal_event_set_recur_yearly(int stream_id,int year,int month,int day,int interval) create a yearly recurrence */ void php3_mcal_event_set_recur_yearly(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; + pval *streamind,*year,*month,*day,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { + if (myargc !=5 || getParameters(ht,myargc,&streamind,&year,&month,&day,&interval) == FAILURE) { WRONG_PARAM_COUNT; } @@ -1542,9 +1590,6 @@ convert_to_long(year); convert_to_long(month); convert_to_long(day); - convert_to_long(hour); - convert_to_long(min); - convert_to_long(sec); convert_to_long(interval); ind = streamind->value.lval; @@ -1556,7 +1601,6 @@ RETURN_FALSE; } dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); - dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_yearly(mcal_le_struct->event, &endtime, interval->value.lval); Index: php3/functions/php3_mcal.h diff -u php3/functions/php3_mcal.h:1.11 php3/functions/php3_mcal.h:1.12 --- php3/functions/php3_mcal.h:1.11 Mon Sep 13 11:03:12 1999 +++ php3/functions/php3_mcal.h Tue Sep 14 14:15:17 1999 @@ -1,4 +1,4 @@ -/* $Id: php3_mcal.h,v 1.11 1999/09/13 15:03:12 musone Exp $ */ +/* $Id: php3_mcal.h,v 1.12 1999/09/14 18:15:17 musone Exp $ */ #ifndef _INCLUDED_MCAL_H #define _INCLUDED_MCAL_H @@ -71,6 +71,8 @@ void php3_mcal_event_set_recur_monthly_mday(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_event_set_recur_monthly_wday(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_event_set_recur_yearly(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_start_now(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_end_now(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_fetch_current_stream_event(INTERNAL_FUNCTION_PARAMETERS);

« previous php.dev (#10910) next »