exceptions now properly taken into account while exporting data

This commit is contained in:
Frederic Culot 2008-12-14 11:24:19 +00:00
parent f06c1b142f
commit 8900d0f8f2
4 changed files with 26 additions and 30 deletions

View File

@ -1,3 +1,10 @@
2008-12-14 Frederic Culot <frederic@culot.org>
* src/recur.c (recur_day_is_exc): suppressed
* src/recur.c (foreach_date_dump): exception dates are now
properly taken into account
2008-12-13 Frederic Culot <frederic@culot.org> 2008-12-13 Frederic Culot <frederic@culot.org>
* src/recur.c (recur_item_inday) * src/recur.c (recur_item_inday)

View File

@ -1,4 +1,4 @@
/* $calcurse: io.c,v 1.47 2008/12/12 20:44:50 culot Exp $ */ /* $calcurse: io.c,v 1.48 2008/12/14 11:24:19 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -238,7 +238,8 @@ get_export_stream (export_type_t type)
return (stream); return (stream);
} }
/* Travel through each occurence of an item, and execute the given callback /*
* Travel through each occurence of an item, and execute the given callback
* (mainly used to export data). * (mainly used to export data).
*/ */
static void static void
@ -246,14 +247,23 @@ foreach_date_dump (const long date_end, struct rpt_s *rpt, struct days_s *exc,
long item_first_date, long item_dur, char *item_mesg, long item_first_date, long item_dur, char *item_mesg,
cb_dump_t cb_dump, FILE *stream) cb_dump_t cb_dump, FILE *stream)
{ {
long date; long date, item_time;
struct tm lt;
time_t t;
t = item_first_date;
lt = *localtime (&t);
lt.tm_hour = lt.tm_min = lt.tm_sec = 0;
lt.tm_isdst = -1;
date = mktime (&lt);
item_time = item_first_date - date;
date = item_first_date;
while (date <= date_end && date <= rpt->until) while (date <= date_end && date <= rpt->until)
{ {
if (!recur_day_is_exc (date, exc)) if (recur_item_inday (item_first_date, exc, rpt->type, rpt->freq,
rpt->until, date))
{ {
(*cb_dump)(stream, date, item_dur, item_mesg); (*cb_dump)(stream, date + item_time, item_dur, item_mesg);
} }
switch (rpt->type) switch (rpt->type)
{ {
@ -270,9 +280,7 @@ foreach_date_dump (const long date_end, struct rpt_s *rpt, struct days_s *exc,
date = date_sec_change (date, rpt->freq * 12, 0); date = date_sec_change (date, rpt->freq * 12, 0);
break; break;
default: default:
fputs (_("FATAL ERROR in foreach_date_dump: " EXIT (_("incoherent repetition type"));
"incoherent repetition type\n"), stderr);
exit (EXIT_FAILURE);
/* NOTREACHED */ /* NOTREACHED */
break; break;
} }

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.c,v 1.43 2008/12/13 21:41:25 culot Exp $ */ /* $calcurse: recur.c,v 1.44 2008/12/14 11:24:19 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -403,24 +403,6 @@ recur_save_data (FILE *f)
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
} }
/* Given a day as long, check if this day belongs to the list of exceptions for
* the considered item.
*/
int
recur_day_is_exc (long day, struct days_s *item_exc)
{
const int NOT_EXC = 0;
const int EXC = 1;
struct days_s *exc;
for (exc = item_exc; exc != 0; exc = exc->next)
{
if (exc->st == day)
return EXC;
}
return NOT_EXC;
}
/* /*
* Check if the recurrent item belongs to the selected day, * Check if the recurrent item belongs to the selected day,
* and if yes, return the real start time. * and if yes, return the real start time.

View File

@ -1,4 +1,4 @@
/* $calcurse: recur.h,v 1.22 2008/09/16 19:41:36 culot Exp $ */ /* $calcurse: recur.h,v 1.23 2008/12/14 11:24:19 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -100,7 +100,6 @@ struct recur_event_s *recur_event_scan (FILE *, struct tm, int, char,
int, struct tm, char *, int, struct tm, char *,
struct days_s *); struct days_s *);
void recur_save_data (FILE *); void recur_save_data (FILE *);
int recur_day_is_exc (long, struct days_s *);
unsigned recur_item_inday (long, struct days_s *, int, int, unsigned recur_item_inday (long, struct days_s *, int, int,
long, long); long, long);
void recur_event_erase (long, unsigned, unsigned, void recur_event_erase (long, unsigned, unsigned,