AceTime  2.3.0
Date and time classes for Arduino that support timezones from the TZ Database.
ZoneInfoHigh.h
1 /*
2  * MIT License
3  * Copyright (c) 2023 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_ZONE_INFO_HIGH_H
7 #define ACE_TIME_ZONE_INFO_HIGH_H
8 
9 #include <stdint.h>
10 
11 namespace ace_time {
12 namespace zoneinfohigh {
13 
18 template<typename S>
19 struct ZoneContext {
26  static const int16_t kMaxUntilYear = 32767;
27 
34  static const int16_t kMaxYear = kMaxUntilYear - 1;
35 
44  static const int16_t kMinYear = -32767;
45 
47  static const uint8_t kSuffixW = 0x00;
48 
50  static const uint8_t kSuffixS = 0x10;
51 
53  static const uint8_t kSuffixU = 0x20;
54 
56  int16_t const startYear;
57 
59  int16_t const untilYear;
60 
62  int16_t const startYearAccurate;
63 
65  int16_t const untilYearAccurate;
66 
68  int16_t const baseYear;
69 
71  int16_t const maxTransitions;
72 
74  const char* const tzVersion;
75 
77  uint8_t const numFragments;
78 
80  uint8_t const numLetters;;
81 
83  const char* const* const fragments;
84 
86  const char* const* const letters;
87 };
88 
94 template<typename S>
95 struct ZoneRule {
97  int16_t const fromYear;
98 
100  int16_t const toYear;
101 
103  uint8_t const inMonth;
104 
115  uint8_t const onDayOfWeek;
116 
121  int8_t const onDayOfMonth;
122 
132  uint8_t const atTimeModifier;
133 
138  uint16_t const atTimeCode;
139 
145  int8_t const deltaMinutes;
146 
159  uint8_t const letterIndex;
160 };
161 
168 template<typename S>
169 struct ZonePolicy {
170  const ZoneRule<S>* const rules;
171  uint8_t const numRules;
172 };
173 
186 template<typename S>
187 struct ZoneEra {
192  const ZonePolicy<S>* const zonePolicy;
193 
219  const char* const format;
220 
225  int16_t const offsetCode;
226 
228  uint8_t const offsetRemainder;
229 
236  int8_t const deltaMinutes;
237 
241  int16_t const untilYear;
242 
244  uint8_t const untilMonth;
245 
251  uint8_t const untilDay;
252 
257  uint16_t const untilTimeCode;
258 
269  uint8_t const untilTimeModifier;
270 };
271 
276 template<typename S, typename ZC>
277 struct ZoneInfo {
279  const char* const name;
280 
286  uint32_t const zoneId;
287 
289  const ZC* const zoneContext;
290 
306  uint8_t const numEras;
307 
312  const ZoneEra<S>* const eras;
313 
315  const ZoneInfo* const targetInfo;
316 };
317 
318 } // zoneinfohigh
319 } // ace_time
320 
321 #endif
Metadata about the zone database.
Definition: ZoneInfoHigh.h:19
static const uint8_t kSuffixW
Represents 'w' or wall time.
Definition: ZoneInfoHigh.h:47
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
Definition: ZoneInfoHigh.h:71
uint8_t const numLetters
Number of fragments.
Definition: ZoneInfoHigh.h:80
int16_t const untilYear
Until year of the zone files as requested.
Definition: ZoneInfoHigh.h:59
int16_t const startYear
Start year of the zone files as requested.
Definition: ZoneInfoHigh.h:56
int16_t const baseYear
Base year for tiny years.
Definition: ZoneInfoHigh.h:68
static const int16_t kMaxYear
The maximum value fromYear and toYear.
Definition: ZoneInfoHigh.h:34
uint8_t const numFragments
Number of fragments.
Definition: ZoneInfoHigh.h:77
const char *const *const fragments
Zone Name fragment list.
Definition: ZoneInfoHigh.h:80
int16_t const untilYearAccurate
Until year of accurate transitions.
Definition: ZoneInfoHigh.h:65
const char *const *const letters
Zone Rule letters list.
Definition: ZoneInfoHigh.h:86
static const int16_t kMaxUntilYear
The maximum value of untilYear.
Definition: ZoneInfoHigh.h:26
static const uint8_t kSuffixS
Represents 's' or standard time.
Definition: ZoneInfoHigh.h:50
static const int16_t kMinYear
The minimum value of fromYear and toYear.
Definition: ZoneInfoHigh.h:44
static const uint8_t kSuffixU
Represents 'u' or UTC time.
Definition: ZoneInfoHigh.h:53
int16_t const startYearAccurate
Start year of accurate transitions.
Definition: ZoneInfoHigh.h:62
const char *const tzVersion
TZ Database version which generated the zone info.
Definition: ZoneInfoHigh.h:74
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
Definition: ZoneInfoHigh.h:187
const char *const format
Zone abbreviations (e.g.
Definition: ZoneInfoHigh.h:219
int8_t const deltaMinutes
If zonePolicy is nullptr, this is the DST offset in minutes as defined by the RULES column in 'hh:mm'...
Definition: ZoneInfoHigh.h:236
const ZonePolicy< S > *const zonePolicy
Zone policy, determined by the RULES column.
Definition: ZoneInfoHigh.h:192
uint16_t const untilTimeCode
The time field of UNTIL field in 15-second increments.
Definition: ZoneInfoHigh.h:257
uint8_t const untilMonth
The month field in UNTIL (1-12).
Definition: ZoneInfoHigh.h:244
uint8_t const offsetRemainder
The remainder seconds from offsetCode.
Definition: ZoneInfoHigh.h:228
int16_t const offsetCode
UTC offset in 15-second increments.
Definition: ZoneInfoHigh.h:225
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoHigh.h:269
uint8_t const untilDay
The day field in UNTIL (1-31).
Definition: ZoneInfoHigh.h:251
int16_t const untilYear
Era is valid until currentTime < untilYear.
Definition: ZoneInfoHigh.h:241
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfoHigh.h:277
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
Definition: ZoneInfoHigh.h:286
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
Definition: ZoneInfoHigh.h:315
const ZoneEra< S > *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
Definition: ZoneInfoHigh.h:312
uint8_t const numEras
Number of ZoneEra entries.
Definition: ZoneInfoHigh.h:306
const char *const name
Full name of zone (e.g.
Definition: ZoneInfoHigh.h:279
const ZC *const zoneContext
ZoneContext metadata.
Definition: ZoneInfoHigh.h:289
A collection of transition rules which describe the DST rules of a given administrative region.
Definition: ZoneInfoHigh.h:169
A time zone transition rule.
Definition: ZoneInfoHigh.h:95
int16_t const fromYear
FROM year.
Definition: ZoneInfoHigh.h:97
int16_t const toYear
TO year.
Definition: ZoneInfoHigh.h:100
uint8_t const letterIndex
Determined by the LETTER column.
Definition: ZoneInfoHigh.h:159
int8_t const onDayOfMonth
Determined by the ON column.
Definition: ZoneInfoHigh.h:121
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoHigh.h:132
uint8_t const onDayOfWeek
Determined by the ON column.
Definition: ZoneInfoHigh.h:115
uint16_t const atTimeCode
Determined by the AT column in units of 15-seconds from 00:00.
Definition: ZoneInfoHigh.h:138
int8_t const deltaMinutes
Determined by the SAVE column and contains the offset from UTC in minutes.
Definition: ZoneInfoHigh.h:145
uint8_t const inMonth
Determined by the IN column.
Definition: ZoneInfoHigh.h:103