AceTime
1.7.5
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.
|
Base interface for ZoneProcessor classes. More...
#include <ZoneProcessor.h>
Public Member Functions | |
uint8_t | getType () const |
Return the kTypeXxx of the current instance. | |
virtual uint32_t | getZoneId () const =0 |
Return the unique stable zoneId. | |
virtual TimeOffset | getUtcOffset (acetime_t epochSeconds) const =0 |
Return the total UTC offset at epochSeconds, including DST offset. More... | |
virtual TimeOffset | getDeltaOffset (acetime_t epochSeconds) const =0 |
Return the DST delta offset at epochSeconds. More... | |
virtual const char * | getAbbrev (acetime_t epochSeconds) const =0 |
Return the time zone abbreviation at epochSeconds. More... | |
virtual OffsetDateTime | getOffsetDateTime (const LocalDateTime &ldt) const =0 |
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the current ZoneProcessor. More... | |
virtual void | printNameTo (Print &printer) const =0 |
Print a human-readable identifier (e.g. More... | |
virtual void | printShortNameTo (Print &printer) const =0 |
Print a short human-readable identifier (e.g. More... | |
virtual void | setZoneKey (uintptr_t zoneKey)=0 |
Set the opaque zoneKey of this object to a new value, reseting any internally cached information. More... | |
virtual bool | equalsZoneKey (uintptr_t zoneKey) const =0 |
Return true if ZoneProcessor is associated with the given opaque zoneKey. More... | |
Protected Member Functions | |
ZoneProcessor (const ZoneProcessor &)=delete | |
ZoneProcessor & | operator= (const ZoneProcessor &)=delete |
ZoneProcessor (uint8_t type) | |
Constructor. | |
virtual bool | equals (const ZoneProcessor &other) const =0 |
Return true if equal. | |
Protected Attributes | |
const uint8_t | mType |
Friends | |
bool | operator== (const ZoneProcessor &a, const ZoneProcessor &b) |
Base interface for ZoneProcessor classes.
There were 2 options for implmenting the various concrete implementations of ZoneProcessors:
1) Implement only a single getType() method to distinguish the different runtime types of the object. Then use this type information in the TimeZone class to downcast the ZoneProcessor pointer to the correct subclass, and call the correct methods.
2) Fully implement a polymorphic class hierarchy, lifting various common methods (getUtcOffset(), getDeltaOffset(), getAbbrev()) into this interface as virtual methods, then add a virtual equals() method to implement the operator==().
The problem with Option 1 is that the code for both subclasses would be compiled into the program, even if the application used only one of the subclasses. Instead I use Option 2, using a fully polymorphic class hierarchy, adding 3-4 virtual methods. When a program uses only a single subclass, only that particular subclass is included into the program. Unfortunately, this comes at the cost of forcing programs to use the virtual dispatch at runtime for some of the often-used methods.
Definition at line 41 of file ZoneProcessor.h.
|
pure virtual |
Return true if ZoneProcessor is associated with the given opaque zoneKey.
This method should be considered to be private.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
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.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
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.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
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.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
Return the total UTC offset at epochSeconds, including DST offset.
Returns TimeOffset::forError() if an error occurs.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
Print a human-readable identifier (e.g.
"America/Los_Angeles").
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
Print a short human-readable identifier (e.g.
"Los_Angeles")
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.
|
pure virtual |
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++.
Implemented in ace_time::ExtendedZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, ace_time::ExtendedZoneProcessorTemplate< extended::BrokerFactory, extended::ZoneInfoBroker, extended::ZoneEraBroker, extended::ZonePolicyBroker, extended::ZoneRuleBroker >, ace_time::BasicZoneProcessorTemplate< BF, ZIB, ZEB, ZPB, ZRB >, and ace_time::BasicZoneProcessorTemplate< basic::BrokerFactory, basic::ZoneInfoBroker, basic::ZoneEraBroker, basic::ZonePolicyBroker, basic::ZoneRuleBroker >.