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
ace_time::zoneinfolow::ZoneContext
Metadata about the zone database.
Definition: ZoneInfoLow.h:37
ace_time::zoneinfolow::ZoneContext::numLetters
uint8_t const numLetters
Number of fragments.
Definition: ZoneInfoLow.h:113
ace_time::zoneinfolow::ZoneContext::baseYear
int16_t const baseYear
Base year for tiny years.
Definition: ZoneInfoLow.h:101
ace_time::zoneinfolow::ZoneContext::letters
const char *const *const letters
Zone Rule letters list.
Definition: ZoneInfoLow.h:119
ace_time::zoneinfolow::ZoneContext::untilYear
int16_t const untilYear
Until year of the zone files as requested.
Definition: ZoneInfoLow.h:92
ace_time::zoneinfolow::ZoneContext::kMinYear
static const int16_t kMinYear
The minimum value of fromYear and toYear.
Definition: ZoneInfoLow.h:74
ace_time::zoneinfolow::ZoneContext::numFragments
uint8_t const numFragments
Number of fragments.
Definition: ZoneInfoLow.h:110
ace_time::zoneinfolow::ZoneContext::kMaxYearTiny
static const int8_t kMaxYearTiny
Maximum value of fromYearTiny or toYearTiny.
Definition: ZoneInfoLow.h:64
ace_time::zoneinfolow::ZoneContext::kMaxYear
static const int16_t kMaxYear
The maximum value fromYear and toYear.
Definition: ZoneInfoLow.h:61
ace_time::zoneinfolow::ZoneContext::kMaxUntilYearTiny
static const int8_t kMaxUntilYearTiny
Maximum value of untilYearTiny.
Definition: ZoneInfoLow.h:53
ace_time::zoneinfolow::ZoneContext::kInvalidYear
static const int16_t kInvalidYear
Sentinel value for an invalid 16-bit year field.
Definition: ZoneInfoLow.h:39
ace_time::zoneinfolow::ZoneContext::kInvalidYearTiny
static const int8_t kInvalidYearTiny
Sentinel value for an invalid 8-bit year field.
Definition: ZoneInfoLow.h:42
ace_time::zoneinfolow::ZoneContext::kMaxUntilYear
static const int16_t kMaxUntilYear
The maximum value of untilYear.
Definition: ZoneInfoLow.h:50
ace_time::zoneinfolow::ZoneContext::kSuffixS
static const uint8_t kSuffixS
Represents 's' or standard time.
Definition: ZoneInfoLow.h:83
ace_time::zoneinfolow::ZoneContext::startYearAccurate
int16_t const startYearAccurate
Start year of accurate transitions.
Definition: ZoneInfoLow.h:95
ace_time::zoneinfolow::ZoneContext::startYear
int16_t const startYear
Start year of the zone files as requested.
Definition: ZoneInfoLow.h:89
ace_time::zoneinfolow::ZoneContext::kSuffixW
static const uint8_t kSuffixW
Represents 'w' or wall time.
Definition: ZoneInfoLow.h:80
ace_time::zoneinfolow::ZoneContext::tzVersion
const char *const tzVersion
TZ Database version which generated the zone info.
Definition: ZoneInfoLow.h:107
ace_time::zoneinfolow::ZoneContext::maxTransitions
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
Definition: ZoneInfoLow.h:104
ace_time::zoneinfolow::ZoneContext::kSuffixU
static const uint8_t kSuffixU
Represents 'u' or UTC time.
Definition: ZoneInfoLow.h:86
ace_time::zoneinfolow::ZoneContext::untilYearAccurate
int16_t const untilYearAccurate
Until year of accurate transitions.
Definition: ZoneInfoLow.h:98
ace_time::zoneinfolow::ZoneContext::kMinYearTiny
static const int8_t kMinYearTiny
The smallest value of a tiny year field.
Definition: ZoneInfoLow.h:77
ace_time::zoneinfolow::ZoneContext::fragments
const char *const *const fragments
Zone Name fragment list.
Definition: ZoneInfoLow.h:113
ace_time::zoneinfolow::ZoneEra
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
Definition: ZoneInfoLow.h:226
ace_time::zoneinfolow::ZoneEra::untilYear
int8_t const untilYear
Era is valid until currentTime < untilYear.
Definition: ZoneInfoLow.h:284
ace_time::zoneinfolow::ZoneEra::zonePolicy
const ZonePolicy< S > *const zonePolicy
Zone policy, determined by the RULES column.
Definition: ZoneInfoLow.h:231
ace_time::zoneinfolow::ZoneEra::format
const char *const format
Zone abbreviations (e.g.
Definition: ZoneInfoLow.h:257
ace_time::zoneinfolow::ZoneEra::untilTimeCode
uint8_t const untilTimeCode
The time field of UNTIL field in 15-minute increments.
Definition: ZoneInfoLow.h:300
ace_time::zoneinfolow::ZoneEra::untilMonth
uint8_t const untilMonth
The month field in UNTIL (1-12).
Definition: ZoneInfoLow.h:287
ace_time::zoneinfolow::ZoneEra::offsetCode
int8_t const offsetCode
UTC offset in 15 min increments.
Definition: ZoneInfoLow.h:260
ace_time::zoneinfolow::ZoneEra::deltaCode
uint8_t const deltaCode
This is a composite of two 4-bit fields:
Definition: ZoneInfoLow.h:279
ace_time::zoneinfolow::ZoneEra::untilDay
uint8_t const untilDay
The day field in UNTIL (1-31).
Definition: ZoneInfoLow.h:294
ace_time::zoneinfolow::ZoneEra::untilTimeModifier
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:312
ace_time::zoneinfolow::ZoneInfo
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfoLow.h:320
ace_time::zoneinfolow::ZoneInfo::targetInfo
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
Definition: ZoneInfoLow.h:358
ace_time::zoneinfolow::ZoneInfo::eras
const ZoneEra< S > *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
Definition: ZoneInfoLow.h:355
ace_time::zoneinfolow::ZoneInfo::zoneContext
const ZC *const zoneContext
ZoneContext metadata.
Definition: ZoneInfoLow.h:332
ace_time::zoneinfolow::ZoneInfo::zoneId
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
Definition: ZoneInfoLow.h:329
ace_time::zoneinfolow::ZoneInfo::name
const char *const name
Full name of zone (e.g.
Definition: ZoneInfoLow.h:322
ace_time::zoneinfolow::ZoneInfo::numEras
uint8_t const numEras
Number of ZoneEra entries.
Definition: ZoneInfoLow.h:349
ace_time::zoneinfolow::ZonePolicy
A collection of transition rules which describe the DST rules of a given administrative region.
Definition: ZoneInfoLow.h:207
ace_time::zoneinfolow::ZoneRule
A time zone transition rule.
Definition: ZoneInfoLow.h:128
ace_time::zoneinfolow::ZoneRule::atTimeCode
uint8_t const atTimeCode
Determined by the AT column in units of 15-minutes from 00:00.
Definition: ZoneInfoLow.h:160
ace_time::zoneinfolow::ZoneRule::letterIndex
uint8_t const letterIndex
Determined by the LETTER column.
Definition: ZoneInfoLow.h:197
ace_time::zoneinfolow::ZoneRule::fromYear
int8_t const fromYear
FROM year.
Definition: ZoneInfoLow.h:130
ace_time::zoneinfolow::ZoneRule::onDayOfWeek
uint8_t const onDayOfWeek
Determined by the ON column.
Definition: ZoneInfoLow.h:148
ace_time::zoneinfolow::ZoneRule::atTimeModifier
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
Definition: ZoneInfoLow.h:171
ace_time::zoneinfolow::ZoneRule::inMonth
uint8_t const inMonth
Determined by the IN column.
Definition: ZoneInfoLow.h:136
ace_time::zoneinfolow::ZoneRule::toYear
int8_t const toYear
TO year.
Definition: ZoneInfoLow.h:133
ace_time::zoneinfolow::ZoneRule::deltaCode
uint8_t const deltaCode
Determined by the SAVE column and contains the offset from UTC, in 15-min increments.
Definition: ZoneInfoLow.h:183
ace_time::zoneinfolow::ZoneRule::onDayOfMonth
int8_t const onDayOfMonth
Determined by the ON column.
Definition: ZoneInfoLow.h:154