3 * \brief Header: time formating macroses
6 #ifndef __UTIL_TIMEFMT_H
7 #define __UTIL_TIMEFMT_H
11 #define INVALID_TIME_TEXT "(invalid)"
15 /* safe localtime formatting - strftime()-using version */
16 #define FMT_LOCALTIME(buffer, bufsize, fmt, when) \
19 whentm = localtime(&when); \
22 strncpy(buffer, INVALID_TIME_TEXT, bufsize); \
23 buffer[bufsize-1] = 0; \
27 strftime(buffer, bufsize, fmt, whentm); \
33 /* fallback when strftime/localtime not available */
34 #define FMT_LOCALTIME(buffer,bufsize,fmt,when) \
36 ctime_r(when,buffer); \
41 #define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \
43 time_t __current_time; \
44 time(&__current_time); \
45 FMT_LOCALTIME(buffer,bufsize,fmt,__current_time); \
48 #endif /* !__UTIL_H */