summaryrefslogtreecommitdiffstats
path: root/src/recur.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/recur.c')
-rw-r--r--src/recur.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/recur.c b/src/recur.c
index 3338017..1c593c2 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -300,17 +300,17 @@ int recur_char2def(char type)
static void recur_write_exc(llist_t * lexc, FILE * f)
{
llist_item_t *i;
- struct tm *lt;
+ struct tm lt;
time_t t;
int st_mon, st_day, st_year;
LLIST_FOREACH(lexc, i) {
struct excp *exc = LLIST_GET_DATA(i);
t = exc->st;
- lt = localtime(&t);
- st_mon = lt->tm_mon + 1;
- st_day = lt->tm_mday;
- st_year = lt->tm_year + 1900;
+ localtime_r(&t, &lt);
+ st_mon = lt.tm_mon + 1;
+ st_day = lt.tm_mday;
+ st_year = lt.tm_year + 1900;
fprintf(f, " !%02u/%02u/%04u", st_mon, st_day, st_year);
}
}
@@ -397,27 +397,27 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
/* Writting of a recursive appointment into file. */
void recur_apoint_write(struct recur_apoint *o, FILE * f)
{
- struct tm *lt;
+ struct tm lt;
time_t t;
t = o->start;
- lt = localtime(&t);
- fprintf(f, "%02u/%02u/%04u @ %02u:%02u", lt->tm_mon + 1, lt->tm_mday,
- 1900 + lt->tm_year, lt->tm_hour, lt->tm_min);
+ localtime_r(&t, &lt);
+ fprintf(f, "%02u/%02u/%04u @ %02u:%02u", lt.tm_mon + 1, lt.tm_mday,
+ 1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
t = o->start + o->dur;
- lt = localtime(&t);
- fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u", lt->tm_mon + 1, lt->tm_mday,
- 1900 + lt->tm_year, lt->tm_hour, lt->tm_min);
+ localtime_r(&t, &lt);
+ fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u", lt.tm_mon + 1, lt.tm_mday,
+ 1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
t = o->rpt->until;
if (t == 0) { /* We have an endless recurrent appointment. */
fprintf(f, " {%d%c", o->rpt->freq, recur_def2char(o->rpt->type));
} else {
- lt = localtime(&t);
+ localtime_r(&t, &lt);
fprintf(f, " {%d%c -> %02u/%02u/%04u", o->rpt->freq,
- recur_def2char(o->rpt->type), lt->tm_mon + 1, lt->tm_mday,
- 1900 + lt->tm_year);
+ recur_def2char(o->rpt->type), lt.tm_mon + 1, lt.tm_mday,
+ 1900 + lt.tm_year);
}
recur_write_exc(&o->exc, f);
fputs("} ", f);
@@ -433,25 +433,25 @@ void recur_apoint_write(struct recur_apoint *o, FILE * f)
/* Writting of a recursive event into file. */
void recur_event_write(struct recur_event *o, FILE * f)
{
- struct tm *lt;
+ struct tm lt;
time_t t;
int st_mon, st_day, st_year;
int end_mon, end_day, end_year;
t = o->day;
- lt = localtime(&t);
- st_mon = lt->tm_mon + 1;
- st_day = lt->tm_mday;
- st_year = lt->tm_year + 1900;
+ localtime_r(&t, &lt);
+ st_mon = lt.tm_mon + 1;
+ st_day = lt.tm_mday;
+ st_year = lt.tm_year + 1900;
t = o->rpt->until;
if (t == 0) { /* We have an endless recurrent event. */
fprintf(f, "%02u/%02u/%04u [%d] {%d%c", st_mon, st_day, st_year, o->id,
o->rpt->freq, recur_def2char(o->rpt->type));
} else {
- lt = localtime(&t);
- end_mon = lt->tm_mon + 1;
- end_day = lt->tm_mday;
- end_year = lt->tm_year + 1900;
+ localtime_r(&t, &lt);
+ end_mon = lt.tm_mon + 1;
+ end_day = lt.tm_mday;
+ end_year = lt.tm_year + 1900;
fprintf(f, "%02u/%02u/%04u [%d] {%d%c -> %02u/%02u/%04u", st_mon,
st_day, st_year, o->id, o->rpt->freq,
recur_def2char(o->rpt->type), end_mon, end_day, end_year);
@@ -563,10 +563,10 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
return 0;
t = day_start;
- lt_day = *localtime(&t);
+ localtime_r(&t, &lt_day);
t = item_start;
- lt_item = *localtime(&t);
+ localtime_r(&t, &lt_item);
lt_item_day = lt_item;
lt_item_day.tm_sec = lt_item_day.tm_min = lt_item_day.tm_hour = 0;
@@ -614,7 +614,7 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
if (rpt_until != 0 && t > rpt_until)
return 0;
- lt_item_day = *localtime(&t);
+ localtime_r(&t, &lt_item_day);
diff = diff_days(lt_item_day, lt_day);
if (diff <= span) {