root/lib/timefmt.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 
   2 /** \file timefmt.h
   3  *  \brief Header: time formatting functions
   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 /*** typedefs(not structures) and defined constants **********************************************/
  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 /* 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     }                                                           \
  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 /*** enums ***************************************************************************************/
  44 
  45 /*** structures declarations (and typedefs of structures)*****************************************/
  46 
  47 /*** global variables defined in .c file *********************************************************/
  48 
  49 extern char *user_recent_timeformat;    /* time format string for recent dates */
  50 extern char *user_old_timeformat;       /* time format string for older dates */
  51 
  52 /*** declarations of public functions ************************************************************/
  53 
  54 size_t i18n_checktimelength (void);
  55 const char *file_date (time_t when);
  56 
  57 /*** inline functions ****************************************************************************/
  58 
  59 #endif /* MC__UTIL_TIMEFMT_H */

/* [previous][next][first][last][top][bottom][index][help]  */