tzfile.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #ifndef TZFILE_H
  2. #define TZFILE_H
  3. /*! \brief
  4. * This file is in the public domain, so clarified as of
  5. * 1996-06-05 by
  6. * \author Arthur David Olson (arthur_david_olson@nih.gov).
  7. *
  8. * \note This header is for use ONLY with the time conversion code.
  9. * There is no guarantee that it will remain unchanged,
  10. * or that it will remain at all.
  11. * Do NOT copy it to any system include directory.
  12. * Thank you!
  13. */
  14. /*
  15. ** ID
  16. */
  17. #ifndef lint
  18. #ifndef NOID
  19. /*
  20. static char tzfilehid[] = "@(#)tzfile.h 7.14";
  21. */
  22. #endif /* !defined NOID */
  23. #endif /* !defined lint */
  24. /*
  25. ** Information about time zone files.
  26. */
  27. #ifndef TZDIR
  28. #define TZDIR "/usr/share/zoneinfo" /*!< Time zone object file directory */
  29. #endif /* !defined TZDIR */
  30. #ifndef TZDEFAULT
  31. #define TZDEFAULT "/etc/localtime"
  32. #endif /* !defined TZDEFAULT */
  33. #ifndef TZDEFRULES
  34. #define TZDEFRULES "posixrules"
  35. #endif /* !defined TZDEFRULES */
  36. /*
  37. ** Each file begins with. . .
  38. */
  39. #define TZ_MAGIC "TZif"
  40. struct tzhead {
  41. char tzh_magic[4]; /* TZ_MAGIC */
  42. char tzh_reserved[16]; /* reserved for future use */
  43. char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
  44. char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
  45. char tzh_leapcnt[4]; /* coded number of leap seconds */
  46. char tzh_timecnt[4]; /* coded number of transition times */
  47. char tzh_typecnt[4]; /* coded number of local time types */
  48. char tzh_charcnt[4]; /* coded number of abbr. chars */
  49. };
  50. /*
  51. ** . . .followed by. . .
  52. **
  53. ** tzh_timecnt (char [4])s coded transition times a la time(2)
  54. ** tzh_timecnt (unsigned char)s types of local time starting at above
  55. ** tzh_typecnt repetitions of
  56. ** one (char [4]) coded UTC offset in seconds
  57. ** one (unsigned char) used to set tm_isdst
  58. ** one (unsigned char) that's an abbreviation list index
  59. ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
  60. ** tzh_leapcnt repetitions of
  61. ** one (char [4]) coded leap second transition times
  62. ** one (char [4]) total correction after above
  63. ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
  64. ** time is standard time, if FALSE,
  65. ** transition time is wall clock time
  66. ** if absent, transition times are
  67. ** assumed to be wall clock time
  68. ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
  69. ** time is UTC, if FALSE,
  70. ** transition time is local time
  71. ** if absent, transition times are
  72. ** assumed to be local time
  73. */
  74. /*
  75. ** In the current implementation, "tzset()" refuses to deal with files that
  76. ** exceed any of the limits below.
  77. */
  78. #ifndef TZ_MAX_TIMES
  79. /*
  80. ** The TZ_MAX_TIMES value below is enough to handle a bit more than a
  81. ** year's worth of solar time (corrected daily to the nearest second) or
  82. ** 138 years of Pacific Presidential Election time
  83. ** (where there are three time zone transitions every fourth year).
  84. */
  85. #define TZ_MAX_TIMES 370
  86. #endif /* !defined TZ_MAX_TIMES */
  87. #ifndef TZ_MAX_TYPES
  88. #ifndef NOSOLAR
  89. #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
  90. #endif /* !defined NOSOLAR */
  91. #ifdef NOSOLAR
  92. /*
  93. ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
  94. ** as noted by Earl Chew <earl@hpato.aus.hp.com>.
  95. */
  96. #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
  97. #endif /* !defined NOSOLAR */
  98. #endif /* !defined TZ_MAX_TYPES */
  99. #ifndef TZ_MAX_CHARS
  100. #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
  101. /* (limited by what unsigned chars can hold) */
  102. #endif /* !defined TZ_MAX_CHARS */
  103. #ifndef TZ_MAX_LEAPS
  104. #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
  105. #endif /* !defined TZ_MAX_LEAPS */
  106. #define SECSPERMIN 60
  107. #define MINSPERHOUR 60
  108. #define HOURSPERDAY 24
  109. #define DAYSPERWEEK 7
  110. #define DAYSPERNYEAR 365
  111. #define DAYSPERLYEAR 366
  112. #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
  113. #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
  114. #define MONSPERYEAR 12
  115. #define TM_SUNDAY 0
  116. #define TM_MONDAY 1
  117. #define TM_TUESDAY 2
  118. #define TM_WEDNESDAY 3
  119. #define TM_THURSDAY 4
  120. #define TM_FRIDAY 5
  121. #define TM_SATURDAY 6
  122. #define TM_JANUARY 0
  123. #define TM_FEBRUARY 1
  124. #define TM_MARCH 2
  125. #define TM_APRIL 3
  126. #define TM_MAY 4
  127. #define TM_JUNE 5
  128. #define TM_JULY 6
  129. #define TM_AUGUST 7
  130. #define TM_SEPTEMBER 8
  131. #define TM_OCTOBER 9
  132. #define TM_NOVEMBER 10
  133. #define TM_DECEMBER 11
  134. #define TM_YEAR_BASE 1900
  135. #define EPOCH_YEAR 1970
  136. #define EPOCH_WDAY TM_THURSDAY
  137. /*
  138. ** Accurate only for the past couple of centuries;
  139. ** that will probably do.
  140. */
  141. #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
  142. #ifndef USG
  143. /*
  144. ** Use of the underscored variants may cause problems if you move your code to
  145. ** certain System-V-based systems; for maximum portability, use the
  146. ** underscore-free variants. The underscored variants are provided for
  147. ** backward compatibility only; they may disappear from future versions of
  148. ** this file.
  149. */
  150. #define SECS_PER_MIN SECSPERMIN
  151. #define MINS_PER_HOUR MINSPERHOUR
  152. #define HOURS_PER_DAY HOURSPERDAY
  153. #define DAYS_PER_WEEK DAYSPERWEEK
  154. #define DAYS_PER_NYEAR DAYSPERNYEAR
  155. #define DAYS_PER_LYEAR DAYSPERLYEAR
  156. #define SECS_PER_HOUR SECSPERHOUR
  157. #define SECS_PER_DAY SECSPERDAY
  158. #define MONS_PER_YEAR MONSPERYEAR
  159. #endif /* !defined USG */
  160. #endif /* !defined TZFILE_H */