tzfmt.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. tzfmt.h
  9. Abstract:
  10. This header contains definitions for the time zone binary file.
  11. Author:
  12. Evan Green 2-Aug-2013
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. #define TIME_ZONE_HEADER_MAGIC 0x6E5A6D54 // 'nZmT'
  21. //
  22. // Define the minimum and maximum years. Insert quip about lack of vision here.
  23. //
  24. #define MIN_TIME_ZONE_YEAR 1
  25. #define MAX_TIME_ZONE_YEAR 9999
  26. //
  27. // Define the minimum and maximum dates. The minimum is
  28. // Midnight on January 1, 0001, and the maximum is one second shy of Midnight
  29. // on January 1, 10000.
  30. //
  31. #define MIN_TIME_ZONE_DATE (LONGLONG)(-63113904000LL)
  32. #define MAX_TIME_ZONE_DATE (LONGLONG)(252423993599LL)
  33. //
  34. // Define the year in which time is "zero" (at midnight on January 1st, GMT).
  35. // This works out to being on a 400 year cycle, which makes calculations easier.
  36. //
  37. #define TIME_ZONE_EPOCH_YEAR 2001
  38. #define TIME_ZONE_EPOCH_WEEKDAY TimeZoneWeekdayMonday
  39. //
  40. // ------------------------------------------------------ Data Type Definitions
  41. //
  42. typedef enum _TIME_ZONE_MONTH {
  43. TimeZoneMonthJanuary,
  44. TimeZoneMonthFebruary,
  45. TimeZoneMonthMarch,
  46. TimeZoneMonthApril,
  47. TimeZoneMonthMay,
  48. TimeZoneMonthJune,
  49. TimeZoneMonthJuly,
  50. TimeZoneMonthAugust,
  51. TimeZoneMonthSeptember,
  52. TimeZoneMonthOctober,
  53. TimeZoneMonthNovember,
  54. TimeZoneMonthDecember,
  55. TimeZoneMonthCount
  56. } TIME_ZONE_MONTH, *PTIME_ZONE_MONTH;
  57. typedef enum _TIME_ZONE_WEEKDAY {
  58. TimeZoneWeekdaySunday,
  59. TimeZoneWeekdayMonday,
  60. TimeZoneWeekdayTuesday,
  61. TimeZoneWeekdayWednesday,
  62. TimeZoneWeekdayThursday,
  63. TimeZoneWeekdayFriday,
  64. TimeZoneWeekdaySaturday,
  65. TimeZoneWeekdayCount
  66. } TIME_ZONE_WEEKDAY, *PTIME_ZONE_WEEKDAY;
  67. typedef enum _TIME_ZONE_OCCASION_TYPE {
  68. TimeZoneOccasionInvalid,
  69. TimeZoneOccasionMonthDate,
  70. TimeZoneOccasionLastWeekday,
  71. TimeZoneOccasionGreaterOrEqualWeekday,
  72. TimeZoneOccasionLessOrEqualWeekday,
  73. } TIME_ZONE_OCCASION_TYPE, *PTIME_ZONE_OCCASION_TYPE;
  74. typedef enum _TIME_ZONE_LENS {
  75. TimeZoneLensInvalid,
  76. TimeZoneLensLocalTime,
  77. TimeZoneLensLocalStandardTime,
  78. TimeZoneLensUtc
  79. } TIME_ZONE_LENS, *PTIME_ZONE_LENS;
  80. /*++
  81. Structure Description:
  82. This structure stores the global file header for the time zone file.
  83. Members:
  84. Magic - Stores a known constant (see TIME_ZONE_HEADER_MAGIC).
  85. RuleOffset - Stores the file offset for the array of rules.
  86. RuleCount - Stores the count of rules.
  87. ZoneOffset - Stores the file offset for the array of time zones.
  88. ZoneCount - Stores the number of time zones in the array.
  89. ZoneEntryOffset - Stores the file offset for the entries in a time zone.
  90. ZoneEntryCount - Stores the number of zone entries in the array.
  91. LeapOffset - Stores the file offset for all the leap seconds.
  92. LeapCount - Stores the count of leap second entries in the array.
  93. StringsOffset - Stores the offset into the string table.
  94. StringsSize - Stores the size of the string table in bytes.
  95. --*/
  96. #pragma pack(push, 1)
  97. typedef struct _TIME_ZONE_HEADER {
  98. ULONG Magic;
  99. ULONG RuleOffset;
  100. ULONG RuleCount;
  101. ULONG ZoneOffset;
  102. ULONG ZoneCount;
  103. ULONG ZoneEntryOffset;
  104. ULONG ZoneEntryCount;
  105. ULONG LeapOffset;
  106. ULONG LeapCount;
  107. ULONG StringsOffset;
  108. ULONG StringsSize;
  109. } PACKED TIME_ZONE_HEADER, *PTIME_ZONE_HEADER;
  110. /*++
  111. Structure Description:
  112. This structure stores information about on occasion when a time zone or rule
  113. becomes active.
  114. Members:
  115. Type - Stores the type of occasion (see TIME_ZONE_OCCASION_TYPE).
  116. MonthDay - Stores the day of the month when the rule becomes valid (if
  117. relevant to the type).
  118. Weekday - Stores the day of the week when the rule becomes valid (if
  119. relevant to the type).
  120. --*/
  121. typedef struct _TIME_ZONE_OCCASION {
  122. CHAR Type;
  123. CHAR MonthDay;
  124. CHAR Weekday;
  125. } PACKED TIME_ZONE_OCCASION, *PTIME_ZONE_OCCASION;
  126. /*++
  127. Structure Description:
  128. This structure stores the structure of a time zone rule in the time zone
  129. file.
  130. Members:
  131. Number - Stores the rule number for this rule.
  132. From - Stores the starting year this rule was in effect.
  133. To - Stores the ending year this rule was is in effect.
  134. Month - Stores the month this rule applies to.
  135. On - Stores the occasion this rule applies on.
  136. At - Storse the time this rule applies.
  137. AtLens - Stores the lens with which to view the at time.
  138. Padding - Stores padding used to align this structure.
  139. Save - Stores the amount of time to save in seconds.
  140. Letters - Stores an offset into the string table where the letters used for
  141. substitution are placed.
  142. --*/
  143. typedef struct _TIME_ZONE_RULE {
  144. ULONG Number;
  145. SHORT From;
  146. SHORT To;
  147. CHAR Month;
  148. TIME_ZONE_OCCASION On;
  149. LONG At;
  150. CHAR AtLens;
  151. CHAR Padding[3];
  152. LONG Save;
  153. ULONG Letters;
  154. } PACKED TIME_ZONE_RULE, *PTIME_ZONE_RULE;
  155. /*++
  156. Structure Description:
  157. This structure stores information about a time zone.
  158. Members:
  159. Name - Stores an offset into the string table where the name of this time
  160. zone resides.
  161. EntryIndex - Stores the index into the array of time zone entries where the
  162. entries for this time zone begin.
  163. EntryCount - Stores the count of valid time zone entries in the array.
  164. --*/
  165. typedef struct _TIME_ZONE {
  166. ULONG Name;
  167. ULONG EntryIndex;
  168. ULONG EntryCount;
  169. } PACKED TIME_ZONE, *PTIME_ZONE;
  170. /*++
  171. Structure Description:
  172. This structure stores information about a time zone entry.
  173. Members:
  174. GmtOffset - Stores the offset in seconds from GMT.
  175. Rules - Stores the number of a set of rules by which this time zone entry
  176. abides. This may be -1 if no rules apply.
  177. Save - Stores the direct amount of time to save.
  178. Format - Stores an offset into the string table where a string containing
  179. the abbreviated format of the time zone will be returned. If there's
  180. a slash, that separates the Standard time from Daylight time
  181. (ie PST/PDT). If there's a %s, then the "letters" string in the applied
  182. rule should be substituted.
  183. Until - Stores the date until which this zone entry applies.
  184. --*/
  185. typedef struct _TIME_ZONE_ENTRY {
  186. LONG GmtOffset;
  187. ULONG Rules;
  188. LONG Save;
  189. ULONG Format;
  190. LONGLONG Until;
  191. } PACKED TIME_ZONE_ENTRY, *PTIME_ZONE_ENTRY;
  192. /*++
  193. Structure Description:
  194. This structure stores information about a leap second.
  195. Members:
  196. Date - Stores the date at which this leap second occurred.
  197. Positive - Stores a non-zero value if the leap second was positive (a
  198. second was added to the normal course of time) or 0 if the second was
  199. negative (a second was removed from the normal course of time).
  200. LocalTime - Stores a non-zero value if the leap second was "rolling",
  201. meaning the given date is in local time. Stores 0 if the leap second
  202. was "stationary", meaning the given date is in GMT.
  203. Padding - Stores a reserved byte currently used to align the structure.
  204. --*/
  205. typedef struct _TIME_ZONE_LEAP_SECOND {
  206. LONGLONG Date;
  207. CHAR Positive;
  208. CHAR LocalTime;
  209. CHAR Padding;
  210. } PACKED TIME_ZONE_LEAP_SECOND, *PTIME_ZONE_LEAP_SECOND;
  211. #pragma pack(pop)
  212. //
  213. // -------------------------------------------------------------------- Globals
  214. //
  215. //
  216. // -------------------------------------------------------- Function Prototypes
  217. //