Clarify panel->currrent if file panel is empty.
[midnight-commander.git] / lib / timefmt.h
blob7e3a1d780c8562396b94bd60d35314132d95ead0
2 /** \file timefmt.h
3 * \brief Header: time formatting functions
4 */
6 #ifndef MC__UTIL_TIMEFMT_H
7 #define MC__UTIL_TIMEFMT_H
9 #include <sys/time.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) \
22 { \
23 struct tm *whentm; \
24 whentm = localtime(&when); \
25 if (whentm == NULL) \
26 { \
27 strncpy(buffer, INVALID_TIME_TEXT, bufsize); \
28 buffer[bufsize-1] = 0; \
29 } \
30 else \
31 { \
32 strftime(buffer, bufsize, fmt, whentm); \
33 } \
34 } \
36 #define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \
37 { \
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 when);
57 /*** inline functions ****************************************************************************/
59 #endif /* MC__UTIL_TIMEFMT_H */