use strftime instead of snprintf wherever possible
This commit is contained in:
parent
a86b73ab03
commit
814d54c676
|
@ -144,10 +144,10 @@ char *log_build_filename(log_t *logdata, const char *destination)
|
||||||
|
|
||||||
time(&s);
|
time(&s);
|
||||||
now = localtime(&s);
|
now = localtime(&s);
|
||||||
snprintf(year, 5, "%04d", now->tm_year + 1900);
|
strftime(year, 5, "%Y", now);
|
||||||
snprintf(day, 3, "%02d", now->tm_mday);
|
strftime(day, 3, "%d", now);
|
||||||
snprintf(month, 3, "%02d", now->tm_mon + 1);
|
strftime(month, 3, "%m", now);
|
||||||
snprintf(hour, 3, "%02d", now->tm_hour);
|
strftime(hour, 3, "%H", now);
|
||||||
snprintf(logfile, MAX_PATH_LEN, "%s/%s", conf_log_root,
|
snprintf(logfile, MAX_PATH_LEN, "%s/%s", conf_log_root,
|
||||||
conf_log_format);
|
conf_log_format);
|
||||||
replace_var(logfile, "%u", logdata->user->name, MAX_PATH_LEN);
|
replace_var(logfile, "%u", logdata->user->name, MAX_PATH_LEN);
|
||||||
|
|
|
@ -122,9 +122,7 @@ char *timestamp(void)
|
||||||
time(&tv);
|
time(&tv);
|
||||||
tm = localtime(&tv);
|
tm = localtime(&tv);
|
||||||
|
|
||||||
snprintf(ts, 20, "%02d-%02d-%04d %02d:%02d:%02d", tm->tm_mday,
|
strftime(ts, 20, "%d-%m-%Y %H:%M:%S", tm);
|
||||||
tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour,
|
|
||||||
tm->tm_min, tm->tm_sec);
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +135,7 @@ char *hrtime(time_t s)
|
||||||
return "never";
|
return "never";
|
||||||
tm = localtime(&s);
|
tm = localtime(&s);
|
||||||
|
|
||||||
snprintf(ts, 20, "%02d-%02d-%04d %02d:%02d:%02d", tm->tm_mday,
|
strftime(ts, 20, "%d-%m-%Y %H:%M:%S", tm);
|
||||||
tm->tm_mon + 1, tm->tm_year + 1900, tm->tm_hour,
|
|
||||||
tm->tm_min, tm->tm_sec);
|
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue