inline void
day_to_str(size_t size, char buf[size], long day)
{
- time_t date;
- const struct tm *tm;
+ time_t date;
+ struct tm tm;
if (day < 0) {
strtcpy(buf, "never", size);
return;
}
- tm = gmtime(&date);
- if (tm == NULL) {
+ if (gmtime_r(&date, &tm) == NULL) {
strtcpy(buf, "future", size);
return;
}
- if (strftime(buf, size, "%Y-%m-%d", tm) == 0)
+ if (strftime(buf, size, "%Y-%m-%d", &tm) == 0)
strtcpy(buf, "future", size);
}
{
char buf[80];
time_t date;
- struct tm *tp;
+ struct tm tm;
if (day < 0) {
puts(_("never"));
return;
}
- tp = gmtime (&date);
- if (NULL == tp) {
+ if (gmtime_r(&date, &tm) == NULL) {
(void) printf ("time_t: %lu\n", (unsigned long)date);
- } else {
- (void) strftime (buf, sizeof buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", tp);
- (void) puts (buf);
+ return;
}
+
+ (void) strftime (buf, sizeof buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm);
+ (void) puts (buf);
}