tzfile.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* $OpenBSD: tzfile.h,v 1.8 2007/02/06 19:35:16 millert Exp $ */
  2. #ifndef TZFILE_H
  3. #define TZFILE_H
  4. /*
  5. ** This file is in the public domain, so clarified as of
  6. ** 1996-06-05 by Arthur David Olson.
  7. */
  8. /*
  9. ** This header is for use ONLY with the time conversion code.
  10. ** There is no guarantee that it will remain unchanged,
  11. ** or that it will remain at all.
  12. ** Do NOT copy it to any system include directory.
  13. ** Thank you!
  14. */
  15. #define SECSPERMIN 60
  16. #define MINSPERHOUR 60
  17. #define HOURSPERDAY 24
  18. #define DAYSPERWEEK 7
  19. #define DAYSPERNYEAR 365
  20. #define DAYSPERLYEAR 366
  21. #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
  22. #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
  23. #define MONSPERYEAR 12
  24. #define TM_SUNDAY 0
  25. #define TM_MONDAY 1
  26. #define TM_TUESDAY 2
  27. #define TM_WEDNESDAY 3
  28. #define TM_THURSDAY 4
  29. #define TM_FRIDAY 5
  30. #define TM_SATURDAY 6
  31. #define TM_JANUARY 0
  32. #define TM_FEBRUARY 1
  33. #define TM_MARCH 2
  34. #define TM_APRIL 3
  35. #define TM_MAY 4
  36. #define TM_JUNE 5
  37. #define TM_JULY 6
  38. #define TM_AUGUST 7
  39. #define TM_SEPTEMBER 8
  40. #define TM_OCTOBER 9
  41. #define TM_NOVEMBER 10
  42. #define TM_DECEMBER 11
  43. #define TM_YEAR_BASE 1900
  44. #define EPOCH_YEAR 1970
  45. #define EPOCH_WDAY TM_THURSDAY
  46. #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
  47. /*
  48. ** Since everything in isleap is modulo 400 (or a factor of 400), we know that
  49. ** isleap(y) == isleap(y % 400)
  50. ** and so
  51. ** isleap(a + b) == isleap((a + b) % 400)
  52. ** or
  53. ** isleap(a + b) == isleap(a % 400 + b % 400)
  54. ** This is true even if % means modulo rather than Fortran remainder
  55. ** (which is allowed by C89 but not C99).
  56. ** We use this to avoid addition overflow problems.
  57. */
  58. #define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
  59. #endif /* !defined TZFILE_H */