From 8ccb487c21368a7fdc8c7c72315325bf0aa06147 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 19:44:12 +0200 Subject: Adding upstream version 3:4.8.29. Signed-off-by: Daniel Baumann --- lib/timefmt.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/timefmt.h (limited to 'lib/timefmt.h') diff --git a/lib/timefmt.h b/lib/timefmt.h new file mode 100644 index 0000000..d2bf191 --- /dev/null +++ b/lib/timefmt.h @@ -0,0 +1,59 @@ + +/** \file timefmt.h + * \brief Header: time formating functions + */ + +#ifndef MC__UTIL_TIMEFMT_H +#define MC__UTIL_TIMEFMT_H + +#include +#include + +/*** typedefs(not structures) and defined constants **********************************************/ + +#define MAX_I18NTIMELENGTH 20 +#define MIN_I18NTIMELENGTH 10 +#define STD_I18NTIMELENGTH 12 + +#define INVALID_TIME_TEXT "(invalid)" + +/* safe localtime formatting - strftime()-using version */ +#define FMT_LOCALTIME(buffer, bufsize, fmt, when) \ + { \ + struct tm *whentm; \ + whentm = localtime(&when); \ + if (whentm == NULL) \ + { \ + strncpy(buffer, INVALID_TIME_TEXT, bufsize); \ + buffer[bufsize-1] = 0; \ + } \ + else \ + { \ + strftime(buffer, bufsize, fmt, whentm); \ + } \ + } \ + +#define FMT_LOCALTIME_CURRENT(buffer, bufsize, fmt) \ + { \ + time_t __current_time; \ + time(&__current_time); \ + FMT_LOCALTIME(buffer,bufsize,fmt,__current_time); \ + } + +/*** enums ***************************************************************************************/ + +/*** structures declarations (and typedefs of structures)*****************************************/ + +/*** global variables defined in .c file *********************************************************/ + +extern char *user_recent_timeformat; /* time format string for recent dates */ +extern char *user_old_timeformat; /* time format string for older dates */ + +/*** declarations of public functions ************************************************************/ + +size_t i18n_checktimelength (void); +const char *file_date (time_t when); + +/*** inline functions ****************************************************************************/ + +#endif /* MC__UTIL_TIMEFMT_H */ -- cgit v1.2.3