AceTime
1.8.0
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
|
An implementation of ZoneProcessor that supports for all zones defined by the TZ Database. More...
#include <ExtendedZoneProcessor.h>
Public Types | |
typedef extended::TransitionTemplate< ZEB, ZPB, ZRB > | Transition |
Exposed only for testing purposes. | |
typedef extended::MatchingEraTemplate< ZEB > | MatchingEra |
Exposed only for testing purposes. | |
typedef extended::TransitionStorageTemplate< kMaxTransitions, ZEB, ZPB, ZRB > | TransitionStorage |
Exposed only for testing purposes. | |
Public Member Functions | |
uint32_t | getZoneId () const override |
Return the unique stable zoneId. | |
TimeOffset | getUtcOffset (acetime_t epochSeconds) const override |
Return the total UTC offset at epochSeconds, including DST offset. More... | |
TimeOffset | getDeltaOffset (acetime_t epochSeconds) const override |
Return the DST delta offset at epochSeconds. More... | |
const char * | getAbbrev (acetime_t epochSeconds) const override |
Return the time zone abbreviation at epochSeconds. More... | |
OffsetDateTime | getOffsetDateTime (const LocalDateTime &ldt) const override |
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the current ZoneProcessor. More... | |
void | printNameTo (Print &printer) const override |
Print a human-readable identifier (e.g. More... | |
void | printShortNameTo (Print &printer) const override |
Print a short human-readable identifier (e.g. More... | |
void | log () const |
Used only for debugging. | |
void | resetTransitionHighWater () |
Reset the TransitionStorage high water mark. More... | |
uint8_t | getTransitionHighWater () const |
Get the TransitionStorage high water mark. More... | |
void | setZoneKey (uintptr_t zoneKey) override |
Set the opaque zoneKey of this object to a new value, reseting any internally cached information. More... | |
bool | equalsZoneKey (uintptr_t zoneKey) const override |
Return true if ZoneProcessor is associated with the given opaque zoneKey. More... | |
void | setBrokerFactory (const BF *brokerFactory) |
Set the broker factory at runtime. More... | |
bool | initForEpochSeconds (acetime_t epochSeconds) const |
Initialize using the epochSeconds. More... | |
bool | initForYear (int16_t year) const |
Initialize the zone rules cache, keyed by the "current" year. More... | |
![]() | |
uint8_t | getType () const |
Return the kTypeXxx of the current instance. | |
Static Public Attributes | |
static const uint8_t | kMaxTransitions = 8 |
Max number of Transitions required for a given Zone, including the most recent prior Transition. More... | |
Protected Member Functions | |
ExtendedZoneProcessorTemplate (uint8_t type, const BF *brokerFactory, uintptr_t zoneKey) | |
Constructor. More... | |
![]() | |
ZoneProcessor (const ZoneProcessor &)=delete | |
ZoneProcessor & | operator= (const ZoneProcessor &)=delete |
ZoneProcessor (uint8_t type) | |
Constructor. | |
Additional Inherited Members | |
![]() | |
const uint8_t | mType |
An implementation of ZoneProcessor that supports for all zones defined by the TZ Database.
The supported zones are defined in the zonedbx/zone_infos.h header file. The constructor expects a pointer to one of the ZoneInfo structures declared in the zonedbx/zone_infos.h file. The zone_processor.py file is the initial Python implementation of this class, which got translated into C++.
Currently (as of v0.7), the underlying zoneinfo files (extended::ZoneInfo, etc) store the UTC and DST offsets of a timezone as a single signed byte in 15-minute increments. This is sufficient to accurate describe all time zones from the year 2000 until 2050. The AT and UNTIL transition times are stored using a 1-minute resolution, which correctly handles the 5 timezones whose DST transition times occur at 00:01. Those zones are:
Not thread-safe.
BF | type of BrokerFactory, needed for implementations that require more complex brokers, and allows this template class to be independent of the exact type of the zone primary key |
ZIB | type of ZoneInfoBroker |
ZEB | type of ZoneEraBroker |
ZPB | type of ZonePolicyBroker |
ZRB | type of ZoneRuleBroker |
Definition at line 783 of file ExtendedZoneProcessor.h.
|
inlineexplicitprotected |
Constructor.
brokerFactory | pointer to a BrokerFactory that creates a ZIB |
zoneKey | an opaque Zone primary key (e.g. const ZoneInfo*) |
Definition at line 1035 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Return true if ZoneProcessor is associated with the given opaque zoneKey.
This method should be considered to be private.
Implements ace_time::ZoneProcessor.
Definition at line 930 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Return the time zone abbreviation at epochSeconds.
Returns an empty string ("") if an error occurs. The returned pointer points to a char buffer that could get overriden by subsequent method calls to this object. The pointer must not be stored permanently, it should be used as soon as possible (e.g. printed out).
This is an experimental method that has not been tested thoroughly. Use with caution.
Implements ace_time::ZoneProcessor.
Definition at line 824 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Return the DST delta offset at epochSeconds.
This is an experimental method that has not been tested thoroughly. Use with caution. Returns TimeOffset::forError() if an error occurs.
Implements ace_time::ZoneProcessor.
Definition at line 817 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the current ZoneProcessor.
Returns OffsetDateTime::forError() if an error occurs, for example, if the LocalDateTime is outside of the support date range of the underlying ZoneInfo files.
Implements ace_time::ZoneProcessor.
Definition at line 831 of file ExtendedZoneProcessor.h.
|
inline |
Get the TransitionStorage high water mark.
For debugging.
Definition at line 916 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Return the total UTC offset at epochSeconds, including DST offset.
Returns TimeOffset::forError() if an error occurs.
Implements ace_time::ZoneProcessor.
Definition at line 807 of file ExtendedZoneProcessor.h.
|
inline |
Initialize using the epochSeconds.
The epochSeconds is converted to the LocalDate for UTC time, and the year is used to call initForYear(). Exposed for debugging.
Definition at line 949 of file ExtendedZoneProcessor.h.
|
inline |
Initialize the zone rules cache, keyed by the "current" year.
Returns success status: true if successful, false if an error occurred. Exposed for debugging.
Definition at line 959 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Print a human-readable identifier (e.g.
"America/Los_Angeles").
Implements ace_time::ZoneProcessor.
Definition at line 889 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Print a short human-readable identifier (e.g.
"Los_Angeles")
Implements ace_time::ZoneProcessor.
Definition at line 893 of file ExtendedZoneProcessor.h.
|
inline |
Reset the TransitionStorage high water mark.
For debugging.
Definition at line 911 of file ExtendedZoneProcessor.h.
|
inline |
Set the broker factory at runtime.
This is an advanced usage where the custom subclass of ExtendedZoneProcessorTemplate does not know its broker factory at compile time, so it must be set at runtime through this method.
Definition at line 940 of file ExtendedZoneProcessor.h.
|
inlineoverridevirtual |
Set the opaque zoneKey of this object to a new value, reseting any internally cached information.
Normally a ZoneProcessor object is associated with a single TimeZone. However, the ZoneProcessorCache will sometimes "take over" a ZoneProcessor from another TimeZone using this method. The other TimeZone will take back control of the ZoneProcessor if needed. To avoid bouncing the ownership of this object repeatedly, the ZoneProcessorCache should allocate enough ZoneProcessors to handle the usage pattern.
This method should be considered to be private, to be used only by the TimeZone and ZoneProcessorCache classes. I had to make it public because it got too ugly to maintain the friend
list in C++.
Implements ace_time::ZoneProcessor.
Definition at line 920 of file ExtendedZoneProcessor.h.
|
static |
Max number of Transitions required for a given Zone, including the most recent prior Transition.
This value for each Zone is given by the kZoneBufSize{zoneName} constant in the generated zonedb[x]/zone_infos.h
file. The ExtendedPythonTest and ExtendedJavaTest tests show that the maximum is 7. Set this to 8 for safety.
Definition at line 793 of file ExtendedZoneProcessor.h.