123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /*
- * category: [tool for time]
- * apply status: framework & linux
- * edit status:
- * build status: yes
- * description:
- */
- #ifndef __GETTIMEOFDAY_H__
- #define __GETTIMEOFDAY_H__
- #pragma once
- #include "config.h"
- #ifndef _WIN32
- #include <sys/time.h>
- #else
- #ifdef __cplusplus
- extern "C" {
- #endif
- #if defined(_MSC_VER) || defined(__BORLANDC__)
- #define EPOCHFILETIME (116444736000000000i64)
- #else
- #define EPOCHFILETIME (116444736000000000LL)
- #endif
- /* Epoch base year */
- #define EPOCH_YEAR 1970
- /* tm struct members conversion units */
- #define TM_YEAR_BASE 1900 /* tm_year base year */
- #define TM_MONTH_MIN 0 /* tm_mon = 0 - January */
- #define TM_MONTH_MAX 11 /* tm_mon = 11 - December */
- #define MIN_SEC 60 /* seconds in a minute */
- #define HOUR_SEC 3600 /* seconds in an hour */
- #define DAY_SEC 86400 /* seconds in a day */
- #define YEAR_SEC (365 * DAY_SEC) /* seconds in a year */
- #define FOUR_YEAR_SEC (4 * YEAR_SEC + 1) /* seconds in a 4-year period */
- /*
- In every, 400 year period (greg) is an interval of the same
- number of days: 365 x 400 + 97 = 146097
- Also, there are 97 leap days in every such 400 years interval
- */
- #define LEAP_DAYS_IN_GREG 97
- #define GREG_YEARS 400
- #define GREG_DAYS (365 * GREG_YEARS + LEAP_DAYS_IN_GREG)
- #define GREG_SECS (GREG_DAYS * DAY_SEC)
- /* Checks if given year is a leap year. */
- #define IS_LEAP_YEAR(year) \
- (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0))
- #ifndef _TIMEZONE_DEFINED
- struct timezone
- {
- int tz_minuteswest; /* minutes W of Greenwich */
- int tz_dsttime; /* type of dst correction */
- };
- #define _TIMEZONE_DEFINED
- #endif /* _TIMEZONE_DEFINED */
- TOOLKIT_API int gettimeofday(struct timeval *tp, struct timezone *tzp);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif // _WIN32
- #endif //__GETTIMEOFDAY_H__
|