AceTime  2.4.0
Date and time classes for Arduino that support timezones from the TZ Database.
ZoneInfoLow.h
Go to the documentation of this file.
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 
27 #include <stdint.h>
28 
29 namespace ace_time{
30 namespace zoneinfolow {
31 
36 template<typename S>
37 struct ZoneContext {
39  static const int16_t kInvalidYear = -32768;
40 
42  static const int8_t kInvalidYearTiny = -128;
43 
50  static const int16_t kMaxUntilYear = 32767;
51 
53  static const int8_t kMaxUntilYearTiny = 127;
54 
61  static const int16_t kMaxYear = kMaxUntilYear - 1;
62 
64  static const int8_t kMaxYearTiny = kMaxUntilYearTiny - 1;
65 
74  static const int16_t kMinYear = -32767;
75 
77  static const int8_t kMinYearTiny = -127;
78 
80  static const uint8_t kSuffixW = 0x00;
81 
83  static const uint8_t kSuffixS = 0x10;
84 
86  static const uint8_t kSuffixU = 0x20;
87 
89  int16_t const startYear;
90 
92  int16_t const untilYear;
93 
95  int16_t const startYearAccurate;
96 
98  int16_t const untilYearAccurate;
99 
101  int16_t const baseYear;
102 
104  int16_t const maxTransitions;
105 
107  const char* const tzVersion;
108 
110  uint8_t const numFragments;
111 
113  uint8_t const numLetters;;
114 
116  const char* const* const fragments;
117 
119  const char* const* const letters;
120 };
121 
127 template<typename S>
128 struct ZoneRule {
130  int8_t const fromYear;
131 
133  int8_t const toYear;
134 
136  uint8_t const inMonth;
137 
148  uint8_t const onDayOfWeek;
149 
154  int8_t const onDayOfMonth;
155 
160  uint8_t const atTimeCode;
161 
171  uint8_t const atTimeModifier;
172 
183  uint8_t const deltaCode;
184 
197  uint8_t const letterIndex;
198 };
199 
206 template<typename S>
207 struct ZonePolicy {
208  const ZoneRule<S>* const rules;
209  uint8_t const numRules;
210 };
211 
225 template<typename S>
226 struct ZoneEra {
231  const ZonePolicy<S>* const zonePolicy;
232 
257  const char* const format;
258 
260  int8_t const offsetCode;
261 
279  uint8_t const deltaCode;
280 
284  int8_t const untilYear;
285 
287  uint8_t const untilMonth;
288 
294  uint8_t const untilDay;
295 
300  uint8_t const untilTimeCode;
301 
312  uint8_t const untilTimeModifier;
313 };
314 
319 template<typename S, typename ZC>
320 struct ZoneInfo {
322  const char* const name;
323 
329  uint32_t const zoneId;
330 
332  const ZC* const zoneContext;
333 
349  uint8_t const numEras;
350 
355  const ZoneEra<S>* const eras;
356 
358  const ZoneInfo* const targetInfo;
359 };
360 
361 }
362 }
363 
364 #endif
Metadata about the zone database.
Definition: ZoneInfoLow.h:37
uint8_t const numLetters
Number of fragments.
Definition: ZoneInfoLow.h:113
int16_t const baseYear
Base year for tiny years.
Definition: ZoneInfoLow.h:101
const char *const *const letters
Zone Rule letters list.
Definition: ZoneInfoLow.h:119
int16_t const untilYear
Until year of the zone files as requested.
Definition: ZoneInfoLow.h:92
static const int16_t kMinYear
The minimum value of fromYear and toYear.
Definition: ZoneInfoLow.h:74
uint8_t const numFragments
Number of fragments.
Definition: ZoneInfoLow.h:110
static const int8_t kMaxYearTiny
Maximum value of fromYearTiny or toYearTiny.
Definition: ZoneInfoLow.h:64
static const int16_t kMaxYear
The maximum value fromYear and toYear.
Definition: ZoneInfoLow.h:61
static const int8_t kMaxUntilYearTiny
Maximum value of untilYearTiny.
Definition: ZoneInfoLow.h:53
static const int16_t kInvalidYear
Sentinel value for an invalid 16-bit year field.
Definition: ZoneInfoLow.h:39
static const int8_t kInvalidYearTiny
Sentinel value for an invalid 8-bit year field.
Definition: ZoneInfoLow.h:42
static const int16_t kMaxUntilYear
The maximum value of untilYear.
Definition: ZoneInfoLow.h:50
static const uint8_t kSuffixS
Represents 's' or standard time.
Definition: ZoneInfoLow.h:83
int16_t const startYearAccurate
Start year of accurate transitions.
Definition: ZoneInfoLow.h:95
int16_t const startYear
Start year of the zone files as requested.
Definition: ZoneInfoLow.h:89
static const uint8_t kSuffixW
Represents 'w' or wall time.
Definition: ZoneInfoLow.h:80
const char *const tzVersion
TZ Database version which generated the zone info.
Definition: ZoneInfoLow.h:107
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
Definition: ZoneInfoLow.h:104
static const uint8_t kSuffixU
Represents 'u' or UTC time.
Definition: ZoneInfoLow.h:86
int16_t const untilYearAccurate
Until year of accurate transitions.
Definition: ZoneInfoLow.h:98
static const int8_t kMinYearTiny
The smallest value of a tiny year field.
Definition: ZoneInfoLow.h:77
const char *const *const fragments
Zone Name fragment list.
Definition: ZoneInfoLow.h:113
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
Definition: ZoneInfoLow.h:226
int8_t const untilYear
Era is valid until currentTime < untilYear.
Definition: ZoneInfoLow.h:284
const ZonePolicy< S > *const zonePolicy
Zone policy, determined by the RULES column.
Definition: ZoneInfoLow.h:231
const char *const format
Zone abbreviations (e.g.
Definition: ZoneInfoLow.h:257
uint8_t const untilTimeCode
The time field of UNTIL field in 15-minute increments.
Definition: ZoneInfoLow.h:300
uint8_t const untilMonth
The month field in UNTIL (1-12).
Definition: ZoneInfoLow.h:287
int8_t const offsetCode
UTC offset in 15 min increments.
Definition: ZoneInfoLow.h:260
uint8_t const deltaCode
This is a composite of two 4-bit fields:
Definition: ZoneInfoLow.h:279
uint8_t const untilDay
The day field in UNTIL (1-31).
Definition: ZoneInfoLow.h:294
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:312
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfoLow.h:320
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
Definition: ZoneInfoLow.h:358
const ZoneEra< S > *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
Definition: ZoneInfoLow.h:355
const ZC *const zoneContext
ZoneContext metadata.
Definition: ZoneInfoLow.h:332
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
Definition: ZoneInfoLow.h:329
const char *const name
Full name of zone (e.g.
Definition: ZoneInfoLow.h:322
uint8_t const numEras
Number of ZoneEra entries.
Definition: ZoneInfoLow.h:349
A collection of transition rules which describe the DST rules of a given administrative region.
Definition: ZoneInfoLow.h:207
A time zone transition rule.
Definition: ZoneInfoLow.h:128
uint8_t const atTimeCode
Determined by the AT column in units of 15-minutes from 00:00.
Definition: ZoneInfoLow.h:160
uint8_t const letterIndex
Determined by the LETTER column.
Definition: ZoneInfoLow.h:197
int8_t const fromYear
FROM year.
Definition: ZoneInfoLow.h:130
uint8_t const onDayOfWeek
Determined by the ON column.
Definition: ZoneInfoLow.h:148
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:171
uint8_t const inMonth
Determined by the IN column.
Definition: ZoneInfoLow.h:136
int8_t const toYear
TO year.
Definition: ZoneInfoLow.h:133
uint8_t const deltaCode
Determined by the SAVE column and contains the offset from UTC, in 15-min increments.
Definition: ZoneInfoLow.h:183
int8_t const onDayOfMonth
Determined by the ON column.
Definition: ZoneInfoLow.h:154