AceTime  2.3.0
Date and time classes for Arduino that support timezones from the TZ Database.
ZoneInfoLow.h
1 /*
2  * MIT License
3  * Copyright (c) 2023 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_ZONE_INFO_LOW_H
7 #define ACE_TIME_ZONE_INFO_LOW_H
8 
9 #include <stdint.h>
10 
11 namespace ace_time{
12 namespace zoneinfolow {
13 
18 template<typename S>
19 struct ZoneContext {
21  static const int16_t kInvalidYear = -32768;
22 
24  static const int8_t kInvalidYearTiny = -128;
25 
32  static const int16_t kMaxUntilYear = 32767;
33 
35  static const int8_t kMaxUntilYearTiny = 127;
36 
43  static const int16_t kMaxYear = kMaxUntilYear - 1;
44 
46  static const int8_t kMaxYearTiny = kMaxUntilYearTiny - 1;
47 
56  static const int16_t kMinYear = -32767;
57 
59  static const int8_t kMinYearTiny = -127;
60 
62  static const uint8_t kSuffixW = 0x00;
63 
65  static const uint8_t kSuffixS = 0x10;
66 
68  static const uint8_t kSuffixU = 0x20;
69 
71  int16_t const startYear;
72 
74  int16_t const untilYear;
75 
77  int16_t const startYearAccurate;
78 
80  int16_t const untilYearAccurate;
81 
83  int16_t const baseYear;
84 
86  int16_t const maxTransitions;
87 
89  const char* const tzVersion;
90 
92  uint8_t const numFragments;
93 
95  uint8_t const numLetters;;
96 
98  const char* const* const fragments;
99 
101  const char* const* const letters;
102 };
103 
109 template<typename S>
110 struct ZoneRule {
112  int8_t const fromYear;
113 
115  int8_t const toYear;
116 
118  uint8_t const inMonth;
119 
130  uint8_t const onDayOfWeek;
131 
136  int8_t const onDayOfMonth;
137 
142  uint8_t const atTimeCode;
143 
153  uint8_t const atTimeModifier;
154 
165  uint8_t const deltaCode;
166 
179  uint8_t const letterIndex;
180 };
181 
188 template<typename S>
189 struct ZonePolicy {
190  const ZoneRule<S>* const rules;
191  uint8_t const numRules;
192 };
193 
206 template<typename S>
207 struct ZoneEra {
212  const ZonePolicy<S>* const zonePolicy;
213 
239  const char* const format;
240 
242  int8_t const offsetCode;
243 
261  uint8_t const deltaCode;
262 
266  int8_t const untilYear;
267 
269  uint8_t const untilMonth;
270 
276  uint8_t const untilDay;
277 
282  uint8_t const untilTimeCode;
283 
294  uint8_t const untilTimeModifier;
295 };
296 
301 template<typename S, typename ZC>
302 struct ZoneInfo {
304  const char* const name;
305 
311  uint32_t const zoneId;
312 
314  const ZC* const zoneContext;
315 
331  uint8_t const numEras;
332 
337  const ZoneEra<S>* const eras;
338 
340  const ZoneInfo* const targetInfo;
341 };
342 
343 }
344 }
345 
346 #endif
Metadata about the zone database.
Definition: ZoneInfoLow.h:19
uint8_t const numLetters
Number of fragments.
Definition: ZoneInfoLow.h:95
int16_t const baseYear
Base year for tiny years.
Definition: ZoneInfoLow.h:83
const char *const *const letters
Zone Rule letters list.
Definition: ZoneInfoLow.h:101
int16_t const untilYear
Until year of the zone files as requested.
Definition: ZoneInfoLow.h:74
static const int16_t kMinYear
The minimum value of fromYear and toYear.
Definition: ZoneInfoLow.h:56
uint8_t const numFragments
Number of fragments.
Definition: ZoneInfoLow.h:92
static const int8_t kMaxYearTiny
Maximum value of fromYearTiny or toYearTiny.
Definition: ZoneInfoLow.h:46
static const int16_t kMaxYear
The maximum value fromYear and toYear.
Definition: ZoneInfoLow.h:43
static const int8_t kMaxUntilYearTiny
Maximum value of untilYearTiny.
Definition: ZoneInfoLow.h:35
static const int16_t kInvalidYear
Sentinel value for an invalid 16-bit year field.
Definition: ZoneInfoLow.h:21
static const int8_t kInvalidYearTiny
Sentinel value for an invalid 8-bit year field.
Definition: ZoneInfoLow.h:24
static const int16_t kMaxUntilYear
The maximum value of untilYear.
Definition: ZoneInfoLow.h:32
static const uint8_t kSuffixS
Represents 's' or standard time.
Definition: ZoneInfoLow.h:65
int16_t const startYearAccurate
Start year of accurate transitions.
Definition: ZoneInfoLow.h:77
int16_t const startYear
Start year of the zone files as requested.
Definition: ZoneInfoLow.h:71
static const uint8_t kSuffixW
Represents 'w' or wall time.
Definition: ZoneInfoLow.h:62
const char *const tzVersion
TZ Database version which generated the zone info.
Definition: ZoneInfoLow.h:89
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
Definition: ZoneInfoLow.h:86
static const uint8_t kSuffixU
Represents 'u' or UTC time.
Definition: ZoneInfoLow.h:68
int16_t const untilYearAccurate
Until year of accurate transitions.
Definition: ZoneInfoLow.h:80
static const int8_t kMinYearTiny
The smallest value of a tiny year field.
Definition: ZoneInfoLow.h:59
const char *const *const fragments
Zone Name fragment list.
Definition: ZoneInfoLow.h:95
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
Definition: ZoneInfoLow.h:207
int8_t const untilYear
Era is valid until currentTime < untilYear.
Definition: ZoneInfoLow.h:266
const ZonePolicy< S > *const zonePolicy
Zone policy, determined by the RULES column.
Definition: ZoneInfoLow.h:212
const char *const format
Zone abbreviations (e.g.
Definition: ZoneInfoLow.h:239
uint8_t const untilTimeCode
The time field of UNTIL field in 15-minute increments.
Definition: ZoneInfoLow.h:282
uint8_t const untilMonth
The month field in UNTIL (1-12).
Definition: ZoneInfoLow.h:269
int8_t const offsetCode
UTC offset in 15 min increments.
Definition: ZoneInfoLow.h:242
uint8_t const deltaCode
This is a composite of two 4-bit fields:
Definition: ZoneInfoLow.h:261
uint8_t const untilDay
The day field in UNTIL (1-31).
Definition: ZoneInfoLow.h:276
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:294
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfoLow.h:302
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
Definition: ZoneInfoLow.h:340
const ZoneEra< S > *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
Definition: ZoneInfoLow.h:337
const ZC *const zoneContext
ZoneContext metadata.
Definition: ZoneInfoLow.h:314
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
Definition: ZoneInfoLow.h:311
const char *const name
Full name of zone (e.g.
Definition: ZoneInfoLow.h:304
uint8_t const numEras
Number of ZoneEra entries.
Definition: ZoneInfoLow.h:331
A collection of transition rules which describe the DST rules of a given administrative region.
Definition: ZoneInfoLow.h:189
A time zone transition rule.
Definition: ZoneInfoLow.h:110
uint8_t const atTimeCode
Determined by the AT column in units of 15-minutes from 00:00.
Definition: ZoneInfoLow.h:142
uint8_t const letterIndex
Determined by the LETTER column.
Definition: ZoneInfoLow.h:179
int8_t const fromYear
FROM year.
Definition: ZoneInfoLow.h:112
uint8_t const onDayOfWeek
Determined by the ON column.
Definition: ZoneInfoLow.h:130
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:153
uint8_t const inMonth
Determined by the IN column.
Definition: ZoneInfoLow.h:118
int8_t const toYear
TO year.
Definition: ZoneInfoLow.h:115
uint8_t const deltaCode
Determined by the SAVE column and contains the offset from UTC, in 15-min increments.
Definition: ZoneInfoLow.h:165
int8_t const onDayOfMonth
Determined by the ON column.
Definition: ZoneInfoLow.h:136