6 #ifndef ACE_TIME_ZONE_INFO_HIGH_H
7 #define ACE_TIME_ZONE_INFO_HIGH_H
29 #include <AceCommon.h>
33 class __FlashStringHelper;
199 uint8_t
const numRules;
354 return int32_t(60) * (int8_t) deltaMinutes;
361 return int32_t(15) * (int16_t) offsetCode + (int32_t) offsetRemainder;
371 return code * (uint32_t) 15 + (modifier & 0x0f);
380 return modifier & 0xf0;
391 : mZoneContext(zoneContext)
400 bool isNull()
const {
return mZoneContext ==
nullptr; }
402 const ZoneContext* raw()
const {
return mZoneContext; }
404 int16_t startYear()
const {
405 return (int16_t) pgm_read_word(&mZoneContext->
startYear);
408 int16_t untilYear()
const {
409 return (int16_t) pgm_read_word(&mZoneContext->
untilYear);
412 int16_t startYearAccurate()
const {
416 int16_t untilYearAccurate()
const {
420 int16_t baseYear()
const {
421 return (int16_t) pgm_read_word(&mZoneContext->
baseYear);
424 int16_t maxTransitions()
const {
428 const __FlashStringHelper* tzVersion()
const {
429 return (
const __FlashStringHelper*)
433 uint8_t numFragments()
const {
434 return (uint8_t) pgm_read_byte(&mZoneContext->
numFragments);
437 uint8_t numLetters()
const {
438 return (uint8_t) pgm_read_byte(&mZoneContext->
numLetters);
441 const __FlashStringHelper*
const* fragments()
const {
442 return (
const __FlashStringHelper*
const*)
446 const __FlashStringHelper* letter(uint8_t i)
const {
447 const char *
const* letters = (
const char*
const*)
448 pgm_read_ptr(&mZoneContext->
letters);
449 const char* letter = (
const char*) pgm_read_ptr(letters + i);
450 return (
const __FlashStringHelper*) letter;
467 : mZoneContext(zoneContext)
468 , mZoneRule(zoneRule)
477 bool isNull()
const {
return mZoneRule ==
nullptr; }
479 int16_t fromYear()
const {
480 return pgm_read_word(&mZoneRule->
fromYear);
483 int16_t toYear()
const {
484 return pgm_read_word(&mZoneRule->
toYear);
487 uint8_t inMonth()
const {
488 return pgm_read_byte(&mZoneRule->
inMonth);
491 uint8_t onDayOfWeek()
const {
495 int8_t onDayOfMonth()
const {
499 uint32_t atTimeSeconds()
const {
505 uint8_t atTimeSuffix()
const {
509 int32_t deltaSeconds()
const {
513 const __FlashStringHelper* letter()
const {
514 uint8_t index = pgm_read_byte(&mZoneRule->
letterIndex);
531 : mZoneContext(zoneContext)
532 , mZonePolicy(zonePolicy)
541 bool isNull()
const {
return mZonePolicy ==
nullptr; }
543 uint8_t numRules()
const {
544 return pgm_read_byte(&mZonePolicy->numRules);
549 (
const ZoneRule*) pgm_read_ptr(&mZonePolicy->rules);
567 const ZoneEra* zoneEra =
nullptr)
568 : mZoneContext(zoneContext)
578 bool isNull()
const {
return mZoneEra ==
nullptr; }
581 return mZoneEra == other.mZoneEra;
590 int32_t offsetSeconds()
const {
596 int32_t deltaSeconds()
const {
600 const char* format()
const {
601 return (
const char*) pgm_read_ptr(&mZoneEra->
format);
604 int16_t untilYear()
const {
605 return pgm_read_word(&mZoneEra->
untilYear);
608 uint8_t untilMonth()
const {
612 uint8_t untilDay()
const {
613 return pgm_read_byte(&mZoneEra->
untilDay);
616 uint32_t untilTimeSeconds()
const {
622 uint8_t untilTimeSuffix()
const {
637 mZoneInfo(zoneInfo) {}
650 return mZoneInfo == (
const ZoneInfo*) zoneKey;
654 return mZoneInfo == zoneInfoBroker.mZoneInfo;
657 bool isNull()
const {
return mZoneInfo ==
nullptr; }
659 const ZoneContextBroker zoneContext()
const {
660 const ZoneContext* context =
661 (
const ZoneContext*) pgm_read_ptr(&mZoneInfo->
zoneContext);
662 return ZoneContextBroker(context);
665 const __FlashStringHelper* name()
const {
666 return FPSTR(pgm_read_ptr(&mZoneInfo->
name));
669 uint32_t zoneId()
const {
670 return pgm_read_dword(&mZoneInfo->
zoneId);
673 uint8_t numEras()
const {
674 return pgm_read_byte(&mZoneInfo->
numEras);
677 const ZoneEraBroker era(uint8_t i)
const {
678 auto eras = (
const ZoneEra*) pgm_read_ptr(&mZoneInfo->
eras);
679 return ZoneEraBroker(zoneContext().raw(), &eras[i]);
682 bool isLink()
const {
686 ZoneInfoBroker targetInfo()
const {
687 return ZoneInfoBroker(
688 (
const ZoneInfo*) pgm_read_ptr(&mZoneInfo->
targetInfo));
694 ace_common::KString kname(name(), zc.fragments(), zc.numFragments());
695 kname.printTo(printer);
703 ace_common::printReplaceCharTo(
704 printer, zoneinfo::findShortName(name()),
'_',
' ');
720 mZoneRegistry(zoneRegistry) {}
728 const ZoneInfo* zoneInfo(uint16_t i)
const {
729 return (
const ZoneInfo*) pgm_read_ptr(&mZoneRegistry[i]);
733 const ZoneInfo*
const* mZoneRegistry;
Helper functions are used in both Basic brokers and Extended brokers.
Data broker for accessing a ZoneContext.
Data broker for accessing ZoneEra.
Data broker for accessing ZoneInfo.
void printShortNameTo(Print &printer) const
Print a short human-readable identifier (e.g.
void printNameTo(Print &printer) const
Print a human-readable identifier (e.g.
bool equals(uintptr_t zoneKey) const
A storage object that creates an ZoneInfoBroker from a key that identifies the ZoneInfo.
ZoneInfoBroker createZoneInfoBroker(uintptr_t zoneKey) const
Data broker for accessing ZonePolicy.
Data broker for accessing the ZoneRegistry.
Data broker for accessing ZoneRule.
Wrapper class so that the entire collection can be referenced as a singel template parameter.
static int32_t toOffsetSeconds(uint16_t offsetCode, uint8_t offsetRemainder)
Convert (code, remainder) holding the STDOFF field of ZoneEra into seconds.
static int32_t toDeltaSeconds(uint8_t deltaMinutes)
Convert the deltaMinutes holding the RULES/DSTOFF field in ZoneEra or the SAVE field in ZoneRule to d...
static uint32_t timeCodeToSeconds(uint16_t code, uint8_t modifier)
Convert (code, modifier) holding the UNTIL time in ZoneInfo or AT time in ZoneRule into seconds.
static uint8_t toSuffix(uint8_t modifier)
Extract the 'w', 's' 'u' suffix from the 'modifier' field, so that they can be compared against kSuff...
Macros and definitions that provide a consistency layer among the various Arduino boards for compatib...
Metadata about the zone database.
int16_t const startYearAccurate
Start year of accurate transitions.
static const int16_t kMinYear
The minimum value of fromYear and toYear.
static const uint8_t kSuffixW
Represents 'w' or wall time.
int16_t const untilYear
Until year of the zone files as requested.
static const int16_t kMaxUntilYear
The maximum value of untilYear.
int16_t const untilYearAccurate
Until year of accurate transitions.
int16_t const startYear
Start year of the zone files as requested.
uint8_t const numLetters
Number of fragments.
int16_t const baseYear
Base year for tiny years.
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
const char *const *const fragments
Zone Name fragment list.
uint8_t const numFragments
Number of fragments.
static const uint8_t kSuffixU
Represents 'u' or UTC time.
static const int16_t kMaxYear
The maximum value fromYear and toYear.
const char *const *const letters
Zone Rule letters list.
static const uint8_t kSuffixS
Represents 's' or standard time.
const char *const tzVersion
TZ Database version which generated the zone info.
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
int16_t const untilYear
Era is valid until currentTime < untilYear.
const char *const format
Zone abbreviations (e.g.
uint8_t const untilMonth
The month field in UNTIL (1-12).
uint8_t const offsetRemainder
The remainder seconds from offsetCode.
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
uint8_t const untilDay
The day field in UNTIL (1-31).
const ZonePolicy *const zonePolicy
Zone policy, determined by the RULES column.
uint16_t const untilTimeCode
The time field of UNTIL field in 15-second increments.
int8_t const deltaMinutes
If zonePolicy is nullptr, this is the DST offset in minutes as defined by the RULES column in 'hh:mm'...
int16_t const offsetCode
UTC offset in 15-second increments.
Representation of a given time zone, implemented as an array of ZoneEra records.
const char *const name
Full name of zone (e.g.
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
const ZoneContext *const zoneContext
ZoneContext metadata.
const ZoneEra *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
uint8_t const numEras
Number of ZoneEra entries.
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
A collection of transition rules which describe the DST rules of a given administrative region.
A time zone transition rule.
uint8_t const letterIndex
Determined by the LETTER column.
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
uint8_t const onDayOfWeek
Determined by the ON column.
int16_t const fromYear
FROM year.
int8_t const deltaMinutes
Determined by the SAVE column and contains the offset from UTC in minutes.
int8_t const onDayOfMonth
Determined by the ON column.
uint16_t const atTimeCode
Determined by the AT column in units of 15-seconds from 00:00.
int16_t const toYear
TO year.
uint8_t const inMonth
Determined by the IN column.