3 * \brief Header: time formating functions
6 #ifndef MC__UTIL_TIMEFMT_H
7 #define MC__UTIL_TIMEFMT_H
10 #include <sys/types.h>
12 /*** typedefs(not structures) and defined constants **********************************************/
14 #define MAX_I18NTIMELENGTH 20
15 #define MIN_I18NTIMELENGTH 10
16 #define STD_I18NTIMELENGTH 12
18 #define INVALID_TIME_TEXT "(invalid)"
20 /* safe localtime formatting - strftime()-using version */
21 #define FMT_LOCALTIME(buffer, bufsize, fmt, when) \
24 whentm = localtime(&when); \
27 strncpy(buffer, INVALID_TIME_TEXT, bufsize); \
28 buffer[bufsize-1] = 0; \
32 strftime(buffer, bufsize, fmt, whentm); \
36 #define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \
38 time_t __current_time; \
39 time(&__current_time); \
40 FMT_LOCALTIME(buffer,bufsize,fmt,__current_time); \
43 /*** enums ***************************************************************************************/
45 /*** structures declarations (and typedefs of structures)*****************************************/
47 /*** global variables defined in .c file *********************************************************/
49 extern char *user_recent_timeformat
; /* time format string for recent dates */
50 extern char *user_old_timeformat
; /* time format string for older dates */
52 /*** declarations of public functions ************************************************************/
54 size_t i18n_checktimelength (void);
55 const char *file_date (time_t);
57 /*** inline functions ****************************************************************************/
59 #endif /* MC__UTIL_TIMEFMT_H */