3 * \brief Header: time formating macroses
6 #ifndef __UTIL_TIMEFMT_H
7 #define __UTIL_TIMEFMT_H
10 #include <sys/types.h>
12 #define INVALID_TIME_TEXT "(invalid)"
14 /* safe localtime formatting - strftime()-using version */
15 #define FMT_LOCALTIME(buffer, bufsize, fmt, when) \
18 whentm = localtime(&when); \
21 strncpy(buffer, INVALID_TIME_TEXT, bufsize); \
22 buffer[bufsize-1] = 0; \
26 strftime(buffer, bufsize, fmt, whentm); \
30 #define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \
32 time_t __current_time; \
33 time(&__current_time); \
34 FMT_LOCALTIME(buffer,bufsize,fmt,__current_time); \
37 #endif /* !__UTIL_H */