6 #ifndef ACE_TIME_ZONE_INFO_MID_H
7 #define ACE_TIME_ZONE_INFO_MID_H
33 #include <AceCommon.h>
37 class __FlashStringHelper;
208 uint8_t
const numRules;
373 return ((int16_t)(deltaCode & 0x0f) - 4) * 15;
383 return ((int8_t)offsetCode * 15) + ((deltaCode & 0xf0) >> 4);
394 return code * (uint16_t) 15 + (modifier & 0x0f);
403 return modifier & 0xf0;
414 : mZoneContext(zoneContext)
423 bool isNull()
const {
return mZoneContext ==
nullptr; }
425 const ZoneContext* raw()
const {
return mZoneContext; }
427 int16_t startYear()
const {
428 return (int16_t) pgm_read_word(&mZoneContext->
startYear);
431 int16_t untilYear()
const {
432 return (int16_t) pgm_read_word(&mZoneContext->
untilYear);
435 int16_t startYearAccurate()
const {
439 int16_t untilYearAccurate()
const {
443 int16_t baseYear()
const {
444 return (int16_t) pgm_read_word(&mZoneContext->
baseYear);
447 int16_t maxTransitions()
const {
451 const __FlashStringHelper* tzVersion()
const {
452 return (
const __FlashStringHelper*)
456 uint8_t numFragments()
const {
457 return (uint8_t) pgm_read_byte(&mZoneContext->
numFragments);
460 uint8_t numLetters()
const {
461 return (uint8_t) pgm_read_byte(&mZoneContext->
numLetters);
464 const __FlashStringHelper*
const* fragments()
const {
465 return (
const __FlashStringHelper*
const*)
469 const __FlashStringHelper* letter(uint8_t i)
const {
470 const char *
const* letters = (
const char*
const*)
471 pgm_read_ptr(&mZoneContext->
letters);
472 const char* letter = (
const char*) pgm_read_ptr(letters + i);
473 return (
const __FlashStringHelper*) letter;
490 : mZoneContext(zoneContext)
491 , mZoneRule(zoneRule)
500 bool isNull()
const {
return mZoneRule ==
nullptr; }
502 int16_t fromYear()
const {
503 return pgm_read_word(&mZoneRule->
fromYear);
506 int16_t toYear()
const {
507 return pgm_read_word(&mZoneRule->
toYear);
510 uint8_t inMonth()
const {
511 return pgm_read_byte(&mZoneRule->
inMonth);
514 uint8_t onDayOfWeek()
const {
518 int8_t onDayOfMonth()
const {
522 uint32_t atTimeSeconds()
const {
528 uint8_t atTimeSuffix()
const {
532 int32_t deltaSeconds()
const {
536 const __FlashStringHelper* letter()
const {
537 uint8_t index = pgm_read_byte(&mZoneRule->
letterIndex);
554 : mZoneContext(zoneContext)
555 , mZonePolicy(zonePolicy)
564 bool isNull()
const {
return mZonePolicy ==
nullptr; }
566 uint8_t numRules()
const {
567 return pgm_read_byte(&mZonePolicy->numRules);
572 (
const ZoneRule*) pgm_read_ptr(&mZonePolicy->rules);
590 const ZoneEra* zoneEra =
nullptr)
591 : mZoneContext(zoneContext)
601 bool isNull()
const {
return mZoneEra ==
nullptr; }
604 return mZoneEra == other.mZoneEra;
613 int32_t offsetSeconds()
const {
619 int32_t deltaSeconds()
const {
623 const char* format()
const {
624 return (
const char*) pgm_read_ptr(&mZoneEra->
format);
627 int16_t untilYear()
const {
628 return pgm_read_word(&mZoneEra->
untilYear);
631 uint8_t untilMonth()
const {
635 uint8_t untilDay()
const {
636 return pgm_read_byte(&mZoneEra->
untilDay);
639 uint32_t untilTimeSeconds()
const {
645 uint8_t untilTimeSuffix()
const {
660 mZoneInfo(zoneInfo) {}
673 return mZoneInfo == (
const ZoneInfo*) zoneKey;
677 return mZoneInfo == zoneInfoBroker.mZoneInfo;
680 bool isNull()
const {
return mZoneInfo ==
nullptr; }
682 const ZoneContextBroker zoneContext()
const {
683 const ZoneContext* context =
684 (
const ZoneContext*) pgm_read_ptr(&mZoneInfo->
zoneContext);
685 return ZoneContextBroker(context);
688 const __FlashStringHelper* name()
const {
689 return FPSTR(pgm_read_ptr(&mZoneInfo->
name));
692 uint32_t zoneId()
const {
693 return pgm_read_dword(&mZoneInfo->
zoneId);
696 uint8_t numEras()
const {
697 return pgm_read_byte(&mZoneInfo->
numEras);
700 const ZoneEraBroker era(uint8_t i)
const {
701 auto eras = (
const ZoneEra*) pgm_read_ptr(&mZoneInfo->
eras);
702 return ZoneEraBroker(zoneContext().raw(), &eras[i]);
705 bool isLink()
const {
709 ZoneInfoBroker targetInfo()
const {
710 return ZoneInfoBroker(
711 (
const ZoneInfo*) pgm_read_ptr(&mZoneInfo->
targetInfo));
717 ace_common::KString kname(name(), zc.fragments(), zc.numFragments());
718 kname.printTo(printer);
726 ace_common::printReplaceCharTo(
727 printer, zoneinfo::findShortName(name()),
'_',
' ');
743 mZoneRegistry(zoneRegistry) {}
751 const ZoneInfo* zoneInfo(uint16_t i)
const {
752 return (
const ZoneInfo*) pgm_read_ptr(&mZoneRegistry[i]);
756 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 uint16_t timeCodeToMinutes(uint8_t code, uint8_t modifier)
Convert (code, modifier) fields representing the UNTIL time in ZoneInfo or AT time in ZoneRule in one...
static int16_t toDeltaMinutes(uint8_t deltaCode)
Convert the deltaCode holding the RULES/DSTOFF field in ZoneEra or the SAVE field in ZoneRule to the ...
static int16_t toOffsetMinutes(uint8_t offsetCode, uint8_t deltaCode)
Convert the offsetCode and deltaCode holding the STDOFF field of the ZoneEra into minutes.
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.
int16_t const startYear
Start year of the zone files as requested.
int16_t const baseYear
Base year for tiny years.
const char *const tzVersion
TZ Database version which generated the zone info.
static const uint8_t kSuffixU
Represents 'u' or UTC time.
int16_t const untilYearAccurate
Until year of accurate transitions.
uint8_t const numFragments
Number of fragments.
static const int16_t kMinYear
The minimum value of fromYear and toYear.
const char *const *const fragments
Zone Name fragment list.
static const int16_t kMaxYear
The maximum value fromYear and toYear.
int16_t const maxTransitions
Max number of transitions required in TransitionStorage.
static const uint8_t kSuffixS
Represents 's' or standard time.
int16_t const untilYear
Until year of the zone files as requested.
static const uint8_t kSuffixW
Represents 'w' or wall time.
const char *const *const letters
Zone Rule letters list.
uint8_t const numLetters
Number of fragments.
static const int16_t kMaxUntilYear
The maximum value of untilYear.
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
uint8_t const untilMonth
The month field in UNTIL (1-12).
const ZonePolicy *const zonePolicy
Zone policy, determined by the RULES column.
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
int16_t const untilYear
Era is valid until currentTime < untilYear.
uint8_t const untilTimeCode
The time field of UNTIL field in 15-minute increments.
int8_t const offsetCode
UTC offset in 15 min increments.
const char *const format
Zone abbreviations (e.g.
uint8_t const deltaCode
This is a composite of two 4-bit fields:
uint8_t const untilDay
The day field in UNTIL (1-31).
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 ZoneEra *const eras
A const ZoneEras* pointer to numEras ZoneEra entries in increasing order of UNTIL time.
uint32_t const zoneId
Unique, stable ID of the zone name, created from a hash of the name.
uint8_t const numEras
Number of ZoneEra entries.
const ZoneContext *const zoneContext
ZoneContext metadata.
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.
int8_t const onDayOfMonth
Determined by the ON column.
uint8_t const deltaCode
Determined by the SAVE column and contains the offset from UTC, in 15-min increments.
int16_t const fromYear
FROM year.
uint8_t const inMonth
Determined by the IN column.
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
uint8_t const atTimeCode
Determined by the AT column in units of 15-minutes from 00:00.
uint8_t const onDayOfWeek
Determined by the ON column.
int16_t const toYear
TO year.