44#define MAX_NAME_SIZE 4096
50#define GET_CENTURY(d) (int) ( (d) / 1000000L)
52#define GET_CCYEAR(d) (int) ( (d) / 10000L)
54#define GET_YEAR(d) (int) (((d) % 1000000L) / 10000L)
56#define GET_MONTH(d) (int) (((d) % 10000L) / 100)
58#define GET_DAY(d) (int) ( (d) % 100)
61#define GET_HOUR(t) (int) ( (t) / 1000000L)
63#define GET_MINUTE(t) (int) (((t) % 1000000L) / 10000L)
65#define GET_SECOND(t) (int) (((t) % 10000L) / 100)
67#define GET_CENTI(t) (int) ( (t) % 100)
70#define MAKE_DATE(c,y,m,d) (long) (c) * 1000000L + \
71 (long) (y) * 10000L + \
72 (long) (m) * 100 + (d)
74#define MAKE_TIME(h,m,s,c) (long) (h) * 1000000L + \
75 (long) (m) * 10000L + \
76 (long) (s) * 100 + (c)
79#define INTERVAL_CENTI 1
80#define INTERVAL_SEC 100
81#define INTERVAL_MIN 6000
82#define INTERVAL_HOUR 360000L
83#define INTERVAL_DAY 8640000L
120 static char date_iso8601[20] ;
127 snprintf(date_iso8601,
sizeof(date_iso8601),
128 "%04d-%02d-%02dT%02d:%02d:%02d",
135 return date_iso8601 ;
171 struct timeval time_struct;
173 gettimeofday (&time_struct, 0);
175 + time_struct.tv_usec / 10000);
193 struct tm *time_struct;
195 if (time_secs == 0) {
199 time_struct = localtime (&time_secs);
201 time_struct-> tm_year += 1900;
202 return (
MAKE_DATE ( time_struct-> tm_year / 100,
203 time_struct-> tm_year % 100,
204 time_struct-> tm_mon + 1,
205 time_struct-> tm_mday));
227 struct tm *time_struct;
229 if (time_secs == 0) {
233 time_struct = localtime (&time_secs);
235 return (
MAKE_TIME (time_struct-> tm_hour,
236 time_struct-> tm_min,
237 time_struct-> tm_sec,
char * xsh_get_datetime_iso8601(void)
Returns the current date and time as a static string.
static long xsh_date_now(void)
Returns the current date as a long (CCYYMMDD).
#define MAKE_DATE(c, y, m, d)
#define MAKE_TIME(h, m, s, c)
static long timer_to_date(time_t time_secs)
Converts a timer value to a date.
static long timer_to_time(time_t time_secs)
Convert a timer value to a time.
static long xsh_time_now(void)
Returns the current time as a long (HHMMSSCC).