recur_repeat_item() and recur_item_inday() prototypes updated to take into account date_t type

This commit is contained in:
Frederic Culot 2007-07-01 17:53:42 +00:00
parent ff0c8aed71
commit 7093cbefb7
2 changed files with 45 additions and 38 deletions

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.c,v 1.25 2007/04/14 18:46:54 culot Exp $ */ /* $calcurse: recur.c,v 1.26 2007/07/01 17:53:42 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -374,6 +374,7 @@ recur_item_inday(long item_start, struct days_s *item_exc,
{ {
#define YEARSTODAYS(x) ((x) * 365L + (x) / 4 - (x) / 100 + (x) / 400) #define YEARSTODAYS(x) ((x) * 365L + (x) / 4 - (x) / 100 + (x) / 400)
date_t start_date;
long day_end; long day_end;
struct tm *lt; struct tm *lt;
int day_month, day_year, day_yday, day_mday, diff; int day_month, day_year, day_yday, day_mday, diff;
@ -440,8 +441,10 @@ recur_item_inday(long item_start, struct days_s *item_exc,
fputs(error, stderr); fputs(error, stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
item_start = date2sec(lt->tm_year + 1900, lt->tm_mon + 1, start_date.dd = lt->tm_mday;
lt->tm_mday, lt->tm_hour, lt->tm_min); start_date.mm = lt->tm_mon + 1;
start_date.yyyy = lt->tm_year + 1900;
item_start = date2sec(start_date, lt->tm_hour, lt->tm_min);
if (item_start < day_end && item_start >= day_start) if (item_start < day_end && item_start >= day_start)
return item_start; return item_start;
@ -565,14 +568,14 @@ void recur_apoint_erase(long start, unsigned num, unsigned delete_whole)
* and then delete the selected item to recreate it as a recurrent one * and then delete the selected item to recreate it as a recurrent one
*/ */
void void
recur_repeat_item(int sel_year, int sel_month, int sel_day, recur_repeat_item(int item_nb)
int item_nb)
{ {
struct tm *lt; struct tm *lt;
time_t t; time_t t;
int ch = 0; int ch = 0;
int valid_date = 0, date_entered = 0; int valid_date = 0, date_entered = 0;
int year = 0, month = 0, day = 0; int year = 0, month = 0, day = 0;
date_t until_date;
char user_input[BUFSIZ] = ""; char user_input[BUFSIZ] = "";
char *mesg_type_1 = char *mesg_type_1 =
_("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early"); _("Enter the repetition type: (D)aily, (W)eekly, (M)onthly, (Y)early");
@ -643,7 +646,10 @@ recur_repeat_item(int sel_year, int sel_month, int sel_day,
sscanf(user_input, "%d / %d / %d", sscanf(user_input, "%d / %d / %d",
&month, &day, &year); &month, &day, &year);
t = p->start; lt = localtime(&t); t = p->start; lt = localtime(&t);
until = date2sec(year, month, day, until_date.dd = day;
until_date.mm = month;
until_date.yyyy = year;
until = date2sec(until_date,
lt->tm_hour, lt->tm_min); lt->tm_hour, lt->tm_min);
if (until < p->start) { if (until < p->start) {
status_mesg(mesg_older, status_mesg(mesg_older,
@ -662,7 +668,7 @@ recur_repeat_item(int sel_year, int sel_month, int sel_day,
return; return;
} }
date = date2sec(sel_year, sel_month, sel_day, 0, 0); date = calendar_get_slctd_day_sec();
day_erase_item(date, item_nb, 0); day_erase_item(date, item_nb, 0);
if (p->type == EVNT) { if (p->type == EVNT) {
re = recur_event_new(p->mesg, p->start, p->evnt_id, re = recur_event_new(p->mesg, p->start, p->evnt_id,

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.h,v 1.11 2007/03/17 16:37:43 culot Exp $ */ /* $calcurse: recur.h,v 1.12 2007/07/01 17:53:42 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -29,6 +29,7 @@
#include "apoint.h" #include "apoint.h"
#include "notify.h" #include "notify.h"
#include "vars.h"
typedef enum { RECUR_NO, typedef enum { RECUR_NO,
RECUR_DAILY, RECUR_DAILY,
@ -77,33 +78,33 @@ extern recur_apoint_llist_t *recur_alist_p;
extern struct recur_event_s *recur_elist; extern struct recur_event_s *recur_elist;
int recur_apoint_llist_init(void); int recur_apoint_llist_init(void);
recur_apoint_llist_node_t *recur_apoint_new(char *mesg, long start, recur_apoint_llist_node_t *recur_apoint_new(char *, long, long, char, int,
long duration, char state, int type, int freq, long until, int, long, struct days_s *);
struct days_s *except); struct recur_event_s *recur_event_new(char *, long, int, int, int,
struct recur_event_s *recur_event_new(char *mesg, long day, int id, long, struct days_s *);
int type, int freq, long until, struct days_s *except); char recur_def2char(int);
char recur_def2char(int define); int recur_char2def(char);
int recur_char2def(char type); void recur_write_exc(struct days_s *, FILE *);
void recur_write_exc(struct days_s *exc, FILE * f); void recur_apoint_write(recur_apoint_llist_node_t *,
void recur_apoint_write(recur_apoint_llist_node_t *o, FILE * f); FILE *);
void recur_event_write(struct recur_event_s *o, FILE * f); void recur_event_write(struct recur_event_s *,
recur_apoint_llist_node_t *recur_apoint_scan(FILE * f, struct tm start, FILE *);
struct tm end, char type, int freq, struct tm until, struct days_s *exc, recur_apoint_llist_node_t *recur_apoint_scan(FILE *, struct tm, struct tm,
char state); char, int, struct tm, struct days_s *,
struct recur_event_s *recur_event_scan(FILE * f, struct tm start, int id, char);
char type, int freq, struct tm until, struct days_s *exc); struct recur_event_s *recur_event_scan(FILE *, struct tm, int, char,
void recur_save_data(FILE *f); int, struct tm, struct days_s *);
unsigned recur_item_inday(long item_start, struct days_s *item_exc, void recur_save_data(FILE *);
int rpt_type, int rpt_freq, long rpt_until, long day_start); unsigned recur_item_inday(long, struct days_s *, int,
void recur_event_erase(long start, unsigned num, unsigned delete_whole); int, long, long);
void recur_apoint_erase(long start, unsigned num, unsigned delete_whole); void recur_event_erase(long, unsigned, unsigned);
void recur_repeat_item(int sel_year, int sel_month, int sel_day, void recur_apoint_erase(long, unsigned, unsigned);
int item_nb); void recur_repeat_item(int);
struct days_s *recur_exc_scan(FILE *data_file); struct days_s *recur_exc_scan(FILE *);
struct notify_app_s *recur_apoint_check_next(struct notify_app_s *app, struct notify_app_s *recur_apoint_check_next(struct notify_app_s *,
long start, long day); long, long);
recur_apoint_llist_node_t *recur_get_apoint(long day, int num); recur_apoint_llist_node_t *recur_get_apoint(long, int);
struct recur_event_s *recur_get_event(long day, int num); struct recur_event_s *recur_get_event(long, int);
void recur_apoint_switch_notify(long date, int recur_nb); void recur_apoint_switch_notify(long, int);
#endif /* CALCURSE_RECUR_H */ #endif /* CALCURSE_RECUR_H */