int all_day_event = 0;
now = time(NULL);
- memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+ localtime_r(&now, &tm_now);
this_year = tm_now.tm_year + 1900;
if (t == NULL) return;
if (t->is_date) all_day_event = 1;
tt = icaltime_as_timet(*t);
if (all_day_event) {
- memcpy(&tm, gmtime(&tt), sizeof(struct tm));
+ gmtime_r(&tt, &tm);
}
else {
- memcpy(&tm, localtime(&tt), sizeof(struct tm));
+ localtime_r(&tt, &tm);
}
wprintf("Month: ");
char vname[SIZ];
tt = time(NULL);
- memcpy(&tm, localtime(&tt), sizeof(struct tm));
+ localtime_r(&tt, &tm);
sprintf(vname, "%s_month", prefix); tm.tm_mon = atoi(bstr(vname)) - 1;
sprintf(vname, "%s_day", prefix); tm.tm_mday = atoi(bstr(vname));
return;
}
- memcpy(&today_tm, localtime(&thetime), sizeof(struct tm));
+ localtime_r(&thetime, &today_tm);
month = today_tm.tm_mon + 1;
day = today_tm.tm_mday;
year = today_tm.tm_year + 1900;
else all_day_event = 0;
if (all_day_event) {
- memcpy(&event_tm, gmtime(&event_tt), sizeof(struct tm));
+ gmtime_r(&event_tt, &event_tm);
}
else {
- memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+ localtime_r(&event_tt, &event_tm);
}
lprintf(9, "Event: %04d/%02d/%02d, Now: %04d/%02d/%02d\n",
memcpy(&tm, &starting_tm, sizeof(struct tm));
while (tm.tm_mday != 1) {
thetime = thetime - (time_t)86400; /* go back 24 hours */
- memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+ localtime_r(&thetime, &tm);
}
/* Determine previous and next months ... for links */
next_month = thetime + (time_t)(31L * 86400L); /* ahead 31 days */
/* Now back up until we're on a Sunday */
- memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+ localtime_r(&thetime, &tm);
while (tm.tm_wday != 0) {
thetime = thetime - (time_t)86400; /* go back 24 hours */
- memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+ localtime_r(&thetime, &tm);
}
/* Outer table (to get the background color) */
wprintf("<TD ALIGN=CENTER>");
- memcpy(&tm, localtime(&previous_month), sizeof(struct tm));
+ localtime_r(&previous_month, &tm);
wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
(int)(tm.tm_year)+1900, tm.tm_mon + 1);
wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
"</FONT>"
" ", months[month-1], year);
- memcpy(&tm, localtime(&next_month), sizeof(struct tm));
+ localtime_r(&next_month, &tm);
wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
(int)(tm.tm_year)+1900, tm.tm_mon + 1);
wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
/* Now do 35 days */
for (i = 0; i < 35; ++i) {
- memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+ localtime_r(&thetime, &tm);
/* Before displaying Sunday, start a new row */
if ((i % 7) == 0) {
}
now = time(NULL);
- memcpy(&today_tm, localtime(&now), sizeof(struct tm));
+ localtime_r(&now, &today_tm);
for (i=0; i<(WC->num_cal); ++i) {
p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
fmt_time(timestring, event_tt);
if (all_day_event) {
- memcpy(&event_tm, gmtime(&event_tt), sizeof(struct tm));
+ gmtime_r(&event_tt, &event_tm);
}
else {
- memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+ localtime_r(&event_tt, &event_tm);
}
if ( (event_tm.tm_year == today_tm.tm_year)
/* In case no date was specified, go with today */
now = time(NULL);
- memcpy(&tm, localtime(&now), sizeof(struct tm));
+ localtime_r(&now, &tm);
year = tm.tm_year + 1900;
month = tm.tm_mon + 1;
day = tm.tm_mday;