Moved dir $(srcdir)/vfs into $(srcdir)/lib/vfs/mc-vfs
[midnight-commander.git] / src / timefmt.h
blobef588670cb89df7b6de42307c69602c9fd78ac60
2 /** \file timefmt.h
3 * \brief Header: time formating macroses
4 */
6 #ifndef __UTIL_TIMEFMT_H
7 #define __UTIL_TIMEFMT_H
9 #include <sys/types.h>
11 #define INVALID_TIME_TEXT "(invalid)"
13 /* safe localtime formatting - strftime()-using version */
14 #define FMT_LOCALTIME(buffer, bufsize, fmt, when) \
15 { \
16 struct tm *whentm; \
17 whentm = localtime(&when); \
18 if (whentm == NULL) \
19 { \
20 strncpy(buffer, INVALID_TIME_TEXT, bufsize); \
21 buffer[bufsize-1] = 0; \
22 } \
23 else \
24 { \
25 strftime(buffer, bufsize, fmt, whentm); \
26 } \
27 } \
29 #define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \
30 { \
31 time_t __current_time; \
32 time(&__current_time); \
33 FMT_LOCALTIME(buffer,bufsize,fmt,__current_time); \
36 #endif /* !__UTIL_H */