1
2
3
4
5
6 #ifndef MC__UTIL_TIMEFMT_H
7 #define MC__UTIL_TIMEFMT_H
8
9 #include <sys/time.h>
10 #include <sys/types.h>
11
12
13
14 #define MAX_I18NTIMELENGTH 20
15 #define MIN_I18NTIMELENGTH 10
16 #define STD_I18NTIMELENGTH 12
17
18 #define INVALID_TIME_TEXT "(invalid)"
19
20
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 }
35
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); \
41 }
42
43
44
45
46
47
48
49 extern char *user_recent_timeformat;
50 extern char *user_old_timeformat;
51
52
53
54 size_t i18n_checktimelength (void);
55 const char *file_date (time_t when);
56
57
58
59 #endif