gettimeofday.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * category: [tool for time]
  3. * apply status: framework & linux
  4. * edit status:
  5. * build status: yes
  6. * description:
  7. */
  8. #ifndef __GETTIMEOFDAY_H__
  9. #define __GETTIMEOFDAY_H__
  10. #pragma once
  11. #include "config.h"
  12. #ifndef _WIN32
  13. #include <sys/time.h>
  14. #else
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #if defined(_MSC_VER) || defined(__BORLANDC__)
  19. #define EPOCHFILETIME (116444736000000000i64)
  20. #else
  21. #define EPOCHFILETIME (116444736000000000LL)
  22. #endif
  23. /* Epoch base year */
  24. #define EPOCH_YEAR 1970
  25. /* tm struct members conversion units */
  26. #define TM_YEAR_BASE 1900 /* tm_year base year */
  27. #define TM_MONTH_MIN 0 /* tm_mon = 0 - January */
  28. #define TM_MONTH_MAX 11 /* tm_mon = 11 - December */
  29. #define MIN_SEC 60 /* seconds in a minute */
  30. #define HOUR_SEC 3600 /* seconds in an hour */
  31. #define DAY_SEC 86400 /* seconds in a day */
  32. #define YEAR_SEC (365 * DAY_SEC) /* seconds in a year */
  33. #define FOUR_YEAR_SEC (4 * YEAR_SEC + 1) /* seconds in a 4-year period */
  34. /*
  35. In every, 400 year period (greg) is an interval of the same
  36. number of days: 365 x 400 + 97 = 146097
  37. Also, there are 97 leap days in every such 400 years interval
  38. */
  39. #define LEAP_DAYS_IN_GREG 97
  40. #define GREG_YEARS 400
  41. #define GREG_DAYS (365 * GREG_YEARS + LEAP_DAYS_IN_GREG)
  42. #define GREG_SECS (GREG_DAYS * DAY_SEC)
  43. /* Checks if given year is a leap year. */
  44. #define IS_LEAP_YEAR(year) \
  45. (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0))
  46. #ifndef _TIMEZONE_DEFINED
  47. struct timezone
  48. {
  49. int tz_minuteswest; /* minutes W of Greenwich */
  50. int tz_dsttime; /* type of dst correction */
  51. };
  52. #define _TIMEZONE_DEFINED
  53. #endif /* _TIMEZONE_DEFINED */
  54. TOOLKIT_API int gettimeofday(struct timeval *tp, struct timezone *tzp);
  55. #ifdef __cplusplus
  56. } // extern "C" {
  57. #endif
  58. #endif // _WIN32
  59. #endif //__GETTIMEOFDAY_H__