2014-05-29 17:06:43 +02:00
|
|
|
/**
|
|
|
|
* \defgroup Time related functions
|
|
|
|
*
|
|
|
|
* This rolls the necessary definition for getting/setting time and
|
|
|
|
* managing local time into one include file, on posix systems this
|
|
|
|
* lives in at least two include files, time.h and sys/time.h
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Definitions for the time module
|
|
|
|
*
|
|
|
|
* \author
|
|
|
|
* Ralf Schlatterbeck <rsc@tux.runtux.com>
|
|
|
|
*/
|
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
#ifndef xtime_h
|
|
|
|
#define xtime_h
|
|
|
|
|
|
|
|
/* This is a time.h implementation but to avoid name-clashes with libs
|
|
|
|
* trying to be helpfull we add the prefix x
|
|
|
|
*/
|
2014-05-29 17:06:43 +02:00
|
|
|
|
2016-02-18 09:55:07 +01:00
|
|
|
#ifdef LOCAL_COMPILE
|
|
|
|
#define clock_seconds() 1
|
|
|
|
#define clock_time() 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEFAULT_TIMEZONE "CET-1CEST,M3.5.0,M10.5.0/3"
|
2014-05-29 17:06:43 +02:00
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
typedef signed long long xtime_t;
|
2014-05-29 17:06:43 +02:00
|
|
|
typedef signed long suseconds_t;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-02-18 09:55:07 +01:00
|
|
|
/* tm_gmtoff and tm_zone are BSD additions */
|
2016-03-29 17:47:03 +02:00
|
|
|
struct xtm {
|
2016-02-18 09:55:07 +01:00
|
|
|
uint32_t tm_year; /* year */
|
|
|
|
uint16_t tm_yday; /* day in the year */
|
|
|
|
uint8_t tm_sec; /* seconds */
|
|
|
|
uint8_t tm_min; /* minutes */
|
|
|
|
uint8_t tm_hour; /* hours */
|
|
|
|
uint8_t tm_mday; /* day of the month */
|
|
|
|
uint8_t tm_mon; /* month */
|
|
|
|
uint8_t tm_wday; /* day of the week */
|
|
|
|
uint8_t tm_isdst; /* daylight saving time */
|
|
|
|
int32_t tm_gmtoff; /* Seconds east of UTC */
|
|
|
|
const char *tm_zone; /* Timezone abbreviation */
|
2014-05-29 17:06:43 +02:00
|
|
|
};
|
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
struct xtimeval {
|
|
|
|
xtime_t tv_sec; /* seconds */
|
2014-05-29 17:06:43 +02:00
|
|
|
suseconds_t tv_usec; /* microseconds */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct timezone {
|
|
|
|
int16_t tz_minuteswest; /* minutes west of Greenwich */
|
|
|
|
int tz_dsttime; /* type of DST correction, unused */
|
|
|
|
};
|
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
struct xtm *xgmtime (const xtime_t *timep);
|
|
|
|
struct xtm *xgmtime_r (const xtime_t *timep, struct xtm *result);
|
|
|
|
struct xtm *xlocaltime (const xtime_t *timep);
|
|
|
|
struct xtm *xlocaltime_r (const xtime_t *timep, struct xtm *result);
|
2014-05-29 17:06:43 +02:00
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
int xgettimeofday (struct xtimeval *tv, struct timezone *tz);
|
|
|
|
int xsettimeofday (const struct xtimeval *tv, const struct timezone *tz);
|
2014-05-29 17:06:43 +02:00
|
|
|
|
2016-02-18 09:55:07 +01:00
|
|
|
/*
|
|
|
|
* Maximum length of all timezone names, this is much longer in UNIX
|
|
|
|
* implementations but we have limited space here. Note that the length
|
|
|
|
* includes a trailing \0 byte for each timezone name.
|
|
|
|
*/
|
|
|
|
#ifndef TZ_MAX_CHARS
|
|
|
|
#define TZ_MAX_CHARS 16
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Maximum length of buffer to reserve for timezone string */
|
|
|
|
#define MAXTZLEN (TZ_MAX_CHARS+9+2*(2+6+1+8)+1)
|
|
|
|
|
|
|
|
int set_tz (const char *tzstring);
|
|
|
|
const char *get_tz (char *buffer, size_t buflen);
|
|
|
|
size_t len_tz (void);
|
|
|
|
|
2014-05-29 17:06:43 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-03-29 17:47:03 +02:00
|
|
|
#endif // xtime_h
|
2014-05-29 17:06:43 +02:00
|
|
|
/** @} */
|