6 #ifndef ACE_TIME_ZONE_INFO_LOW_H
7 #define ACE_TIME_ZONE_INFO_LOW_H
29 #include <AceCommon.h>
33 class __FlashStringHelper;
215 uint8_t
const numRules;
381 return ((int16_t)(deltaCode & 0x0f) - 4) * 15;
391 return ((int8_t)offsetCode * 15) + ((deltaCode & 0xf0) >> 4);
402 return code * (uint16_t) 15 + (modifier & 0x0f);
411 return modifier & 0xf0;
422 : mZoneContext(zoneContext)
431 bool isNull()
const {
return mZoneContext ==
nullptr; }
433 const ZoneContext* raw()
const {
return mZoneContext; }
435 int16_t startYear()
const {
436 return (int16_t) pgm_read_word(&mZoneContext->
startYear);
439 int16_t untilYear()
const {
440 return (int16_t) pgm_read_word(&mZoneContext->
untilYear);
443 int16_t startYearAccurate()
const {
447 int16_t untilYearAccurate()
const {
451 int16_t baseYear()
const {
452 return (int16_t) pgm_read_word(&mZoneContext->
baseYear);
455 int16_t maxTransitions()
const {
459 const __FlashStringHelper* tzVersion()
const {
460 return (
const __FlashStringHelper*)
464 uint8_t numFragments()
const {
465 return (uint8_t) pgm_read_byte(&mZoneContext->
numFragments);
468 uint8_t numLetters()
const {
469 return (uint8_t) pgm_read_byte(&mZoneContext->
numLetters);
472 const __FlashStringHelper*
const* fragments()
const {
473 return (
const __FlashStringHelper*
const*)
477 const __FlashStringHelper* letter(uint8_t i)
const {
478 const char *
const* letters = (
const char*
const*)
479 pgm_read_ptr(&mZoneContext->
letters);
480 const char* letter = (
const char*) pgm_read_ptr(letters + i);
481 return (
const __FlashStringHelper*) letter;
498 : mZoneContext(zoneContext)
499 , mZoneRule(zoneRule)
508 bool isNull()
const {
return mZoneRule ==
nullptr; }
510 int16_t fromYear()
const {
511 int8_t yearTiny = (int8_t) pgm_read_byte(&mZoneRule->
fromYear);
513 return toYearFromTiny(yearTiny, baseYear);
516 int16_t toYear()
const {
517 int8_t yearTiny = (int8_t) pgm_read_byte(&mZoneRule->
toYear);
519 return toYearFromTiny(yearTiny, baseYear);
522 static int16_t toYearFromTiny(int8_t yearTiny, int16_t baseYear) {
534 return baseYear + yearTiny;
537 uint8_t inMonth()
const {
538 return pgm_read_byte(&mZoneRule->
inMonth);
541 uint8_t onDayOfWeek()
const {
545 int8_t onDayOfMonth()
const {
549 uint32_t atTimeSeconds()
const {
555 uint8_t atTimeSuffix()
const {
559 int32_t deltaSeconds()
const {
563 const __FlashStringHelper* letter()
const {
564 uint8_t index = pgm_read_byte(&mZoneRule->
letterIndex);
581 : mZoneContext(zoneContext)
582 , mZonePolicy(zonePolicy)
591 bool isNull()
const {
return mZonePolicy ==
nullptr; }
593 uint8_t numRules()
const {
594 return pgm_read_byte(&mZonePolicy->numRules);
599 (
const ZoneRule*) pgm_read_ptr(&mZonePolicy->rules);
617 const ZoneEra* zoneEra =
nullptr)
618 : mZoneContext(zoneContext)
628 bool isNull()
const {
return mZoneEra ==
nullptr; }
631 return mZoneEra == other.mZoneEra;
640 int32_t offsetSeconds()
const {
646 int32_t deltaSeconds()
const {
650 const char* format()
const {
651 return (
const char*) pgm_read_ptr(&mZoneEra->
format);
654 int16_t untilYear()
const {
655 int8_t yearTiny = (int8_t) pgm_read_byte(&mZoneEra->
untilYear);
657 return toUntilYearFromTiny(yearTiny, baseYear);
660 static int16_t toUntilYearFromTiny(int8_t yearTiny, int16_t baseYear) {
667 return baseYear + yearTiny;
670 uint8_t untilMonth()
const {
674 uint8_t untilDay()
const {
675 return pgm_read_byte(&mZoneEra->
untilDay);
678 uint32_t untilTimeSeconds()
const {
684 uint8_t untilTimeSuffix()
const {
699 mZoneInfo(zoneInfo) {}
712 return mZoneInfo == (
const ZoneInfo*) zoneKey;
716 return mZoneInfo == zoneInfoBroker.mZoneInfo;
719 bool isNull()
const {
return mZoneInfo ==
nullptr; }
721 const ZoneContextBroker zoneContext()
const {
722 const ZoneContext* context =
723 (
const ZoneContext*) pgm_read_ptr(&mZoneInfo->
zoneContext);
724 return ZoneContextBroker(context);
727 const __FlashStringHelper* name()
const {
728 return FPSTR(pgm_read_ptr(&mZoneInfo->
name));
731 uint32_t zoneId()
const {
732 return pgm_read_dword(&mZoneInfo->
zoneId);
735 uint8_t numEras()
const {
736 return pgm_read_byte(&mZoneInfo->
numEras);
739 const ZoneEraBroker era(uint8_t i)
const {
740 auto eras = (
const ZoneEra*) pgm_read_ptr(&mZoneInfo->
eras);
741 return ZoneEraBroker(zoneContext().raw(), &eras[i]);
744 bool isLink()
const {
748 ZoneInfoBroker targetInfo()
const {
749 return ZoneInfoBroker(
750 (
const ZoneInfo*) pgm_read_ptr(&mZoneInfo->
targetInfo));
756 ace_common::KString kname(name(), zc.fragments(), zc.numFragments());
757 kname.printTo(printer);
765 ace_common::printReplaceCharTo(
766 printer, zoneinfo::findShortName(name()),
'_',
' ');
782 mZoneRegistry(zoneRegistry) {}
790 const ZoneInfo* zoneInfo(uint16_t i)
const {
791 return (
const ZoneInfo*) pgm_read_ptr(&mZoneRegistry[i]);
795 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.
bool equals(uintptr_t zoneKey) const
void printNameTo(Print &printer) const
Print a human-readable identifier (e.g.
void printShortNameTo(Print &printer) const
Print a short human-readable identifier (e.g.
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.
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 toOffsetMinutes(uint8_t offsetCode, uint8_t deltaCode)
Convert the offsetCode and deltaCode holding the STDOFF field of the ZoneEra into minutes.
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 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 maxTransitions
Max number of transitions required in TransitionStorage.
static const int8_t kMaxYearTiny
Maximum value of fromYearTiny or toYearTiny.
static const uint8_t kSuffixW
Represents 'w' or wall time.
static const int8_t kInvalidYearTiny
Sentinel value for an invalid 8-bit year field.
static const uint8_t kSuffixS
Represents 's' or standard time.
static const int16_t kMinYear
The minimum value of fromYear and toYear.
static const int16_t kMaxUntilYear
The maximum value of untilYear.
int16_t const untilYearAccurate
Until year of accurate transitions.
static const uint8_t kSuffixU
Represents 'u' or UTC time.
uint8_t const numFragments
Number of fragments.
static const int16_t kInvalidYear
Sentinel value for an invalid 16-bit year field.
int16_t const baseYear
Base year for tiny years.
const char *const tzVersion
TZ Database version which generated the zone info.
const char *const *const letters
Zone Rule letters list.
uint8_t const numLetters
Number of fragments.
static const int16_t kMaxYear
The maximum value fromYear and toYear.
int16_t const startYearAccurate
Start year of accurate transitions.
static const int8_t kMinYearTiny
The smallest value of a tiny year field.
static const int8_t kMaxUntilYearTiny
Maximum value of untilYearTiny.
int16_t const untilYear
Until year of the zone files as requested.
const char *const *const fragments
Zone Name fragment list.
int16_t const startYear
Start year of the zone files as requested.
An entry in ZoneInfo which describes which ZonePolicy was being followed during a particular time per...
uint8_t const untilTimeModifier
The untilTimeModifier is a packed field containing 2 pieces of info:
uint8_t const deltaCode
This is a composite of two 4-bit fields:
int8_t const untilYear
Era is valid until currentTime < untilYear.
int8_t const offsetCode
UTC offset in 15 min increments.
uint8_t const untilDay
The day field in UNTIL (1-31).
const ZonePolicy *const zonePolicy
Zone policy, determined by the RULES column.
uint8_t const untilMonth
The month field in UNTIL (1-12).
const char *const format
Zone abbreviations (e.g.
uint8_t const untilTimeCode
The time field of UNTIL field in 15-minute increments.
Representation of a given time zone, implemented as an array of ZoneEra records.
const ZoneContext *const zoneContext
ZoneContext metadata.
const char *const name
Full name of zone (e.g.
uint8_t const numEras
Number of ZoneEra entries.
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.
const ZoneInfo *const targetInfo
If Link, points to the target zone info.
A collection of transition rules which describe the DST rules of a given administrative region.
A time zone transition rule.
int8_t const toYear
TO year.
int8_t const fromYear
FROM year.
uint8_t const letterIndex
Determined by the LETTER column.
uint8_t const atTimeModifier
The atTimeModifier is a packed field containing 2 pieces of info:
int8_t const onDayOfMonth
Determined by the ON column.
uint8_t const onDayOfWeek
Determined by the ON column.
uint8_t const deltaCode
Determined by the SAVE column and contains the offset from UTC, in 15-min increments.
uint8_t const inMonth
Determined by the IN column.
uint8_t const atTimeCode
Determined by the AT column in units of 15-minutes from 00:00.