tzfile.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Layout and location of TZif files. */
  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. /*
  16. ** Information about time zone files.
  17. */
  18. #ifndef TZDEFRULES
  19. # define TZDEFRULES "posixrules"
  20. #endif /* !defined TZDEFRULES */
  21. /* See Internet RFC 8536 for more details about the following format. */
  22. /*
  23. ** Each file begins with. . .
  24. */
  25. #define TZ_MAGIC "TZif"
  26. struct tzhead {
  27. char tzh_magic[4]; /* TZ_MAGIC */
  28. char tzh_version[1]; /* '\0' or '2'-'4' as of 2021 */
  29. char tzh_reserved[15]; /* reserved; must be zero */
  30. char tzh_ttisutcnt[4]; /* coded number of trans. time flags */
  31. char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
  32. char tzh_leapcnt[4]; /* coded number of leap seconds */
  33. char tzh_timecnt[4]; /* coded number of transition times */
  34. char tzh_typecnt[4]; /* coded number of local time types */
  35. char tzh_charcnt[4]; /* coded number of abbr. chars */
  36. };
  37. /*
  38. ** . . .followed by. . .
  39. **
  40. ** tzh_timecnt (char [4])s coded transition times a la time(2)
  41. ** tzh_timecnt (unsigned char)s types of local time starting at above
  42. ** tzh_typecnt repetitions of
  43. ** one (char [4]) coded UT offset in seconds
  44. ** one (unsigned char) used to set tm_isdst
  45. ** one (unsigned char) that's an abbreviation list index
  46. ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
  47. ** tzh_leapcnt repetitions of
  48. ** one (char [4]) coded leap second transition times
  49. ** one (char [4]) total correction after above
  50. ** tzh_ttisstdcnt (char)s indexed by type; if 1, transition
  51. ** time is standard time, if 0,
  52. ** transition time is local (wall clock)
  53. ** time; if absent, transition times are
  54. ** assumed to be local time
  55. ** tzh_ttisutcnt (char)s indexed by type; if 1, transition
  56. ** time is UT, if 0, transition time is
  57. ** local time; if absent, transition
  58. ** times are assumed to be local time.
  59. ** When this is 1, the corresponding
  60. ** std/wall indicator must also be 1.
  61. */
  62. /*
  63. ** If tzh_version is '2' or greater, the above is followed by a second instance
  64. ** of tzhead and a second instance of the data in which each coded transition
  65. ** time uses 8 rather than 4 chars,
  66. ** then a POSIX.1-2017 proleptic TZ string for use in handling
  67. ** instants after the last transition time stored in the file
  68. ** (with nothing between the newlines if there is no POSIX.1-2017
  69. ** representation for such instants).
  70. **
  71. ** If tz_version is '3' or greater, the TZ string can be any POSIX.1-2024
  72. ** proleptic TZ string, which means the above is extended as follows.
  73. ** First, the TZ string's hour offset may range from -167
  74. ** through 167 as compared to the range 0 through 24 required
  75. ** by POSIX.1-2017 and earlier.
  76. ** Second, its DST start time may be January 1 at 00:00 and its stop
  77. ** time December 31 at 24:00 plus the difference between DST and
  78. ** standard time, indicating DST all year.
  79. */
  80. /*
  81. ** In the current implementation, "tzset()" refuses to deal with files that
  82. ** exceed any of the limits below.
  83. */
  84. #ifndef TZ_MAX_TIMES
  85. /* This must be at least 242 for Europe/London with 'zic -b fat'. */
  86. # define TZ_MAX_TIMES 2000
  87. #endif /* !defined TZ_MAX_TIMES */
  88. #ifndef TZ_MAX_TYPES
  89. /* This must be at least 18 for Europe/Vilnius with 'zic -b fat'. */
  90. # define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
  91. #endif /* !defined TZ_MAX_TYPES */
  92. #ifndef TZ_MAX_CHARS
  93. /* This must be at least 40 for America/Anchorage. */
  94. # define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
  95. /* (limited by what unsigned chars can hold) */
  96. #endif /* !defined TZ_MAX_CHARS */
  97. #ifndef TZ_MAX_LEAPS
  98. /* This must be at least 27 for leap seconds from 1972 through mid-2023.
  99. There's a plan to discontinue leap seconds by 2035. */
  100. # define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
  101. #endif /* !defined TZ_MAX_LEAPS */
  102. #endif /* !defined TZFILE_H */