AceTime
0.3
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 ZoneSpecifier that supports a subset of the zones containing in the TZ Database. More...
#include <BasicZoneSpecifier.h>
Public Member Functions | |
BasicZoneSpecifier (const basic::ZoneInfo *zoneInfo) | |
Constructor. More... | |
const basic::ZoneInfo * | getZoneInfo () const |
Return the underlying ZoneInfo. More... | |
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 |
void | printTo (Print &printer) const override |
Print the TD database zone identifier e.g "America/Los_Angeles". More... | |
void | log () const |
Used only for debugging. More... | |
![]() | |
uint8_t | getType () const |
Return the kTypeXxx of the current instance. More... | |
Static Public Member Functions | |
static uint8_t | calcStartDayOfMonth (int16_t year, uint8_t month, uint8_t onDayOfWeek, uint8_t onDayOfMonth) |
Calculate the actual dayOfMonth of the expresssion (onDayOfWeek >= onDayOfMonth). More... | |
Additional Inherited Members | |
![]() | |
static const uint8_t | kTypeManual = 1 |
Indicate ManualZoneSpecifier. More... | |
static const uint8_t | kTypeBasic = 2 |
Indicate BasicZoneSpecifier. More... | |
static const uint8_t | kTypeExtended = 3 |
Indicate ExtendedZoneSpecifier. More... | |
![]() | |
ZoneSpecifier (const ZoneSpecifier &)=default | |
ZoneSpecifier & | operator= (const ZoneSpecifier &)=default |
ZoneSpecifier (uint8_t type) | |
Constructor. More... | |
![]() | |
uint8_t | mType |
An implementation of ZoneSpecifier that supports a subset of the zones containing in the TZ Database.
The supported list of zones, as well as the list of unsupported zones, are is listed in the zonedb/zone_info.h header file. The constructor expects a pointer to one of the ZoneInfo structures declared in the zone_infos.h file.
The internal ZoneRule and ZoneEra records that match the year of the given epochSeconds are cached for performance. The expectation is that repeated calls to the various methods will have epochSeconds which do not vary too greatly and will occur in the same year.
The Rule records are transition points which look like this:
* Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S *
Each record is represented by basic::ZoneRule and the entire collection is represented by basic::ZonePolicy.
The Zone records define the region which follows a specific set of Rules for certain time periods (given by UNTIL below):
* Zone NAME GMTOFF RULES FORMAT [UNTIL] *
Each record is represented by basic::ZoneEra and the entire collection is represented by basic::ZoneInfo.
This class assumes that the various components of ZoneInfo, ZoneEra, and ZonePolicy, ZoneRule have a number of limitations and constraints which simplify the implementation of this class. The tzcompiler.py script will remove zones which do not meet these constraints when generating the structs defined by zonedb/zone_infos.h. The constraints are at least the following (see tools/transformer.py for the authoratative algorithm):
Even with these limitations, zonedb/zone_info.h shows that 231 out of a total of 359 zones are supported by BasicZoneSpecifier.
Not thread-safe.
Definition at line 140 of file BasicZoneSpecifier.h.
|
inlineexplicit |
Constructor.
zoneInfo | pointer to a ZoneInfo. Must not be nullptr. |
Definition at line 146 of file BasicZoneSpecifier.h.
|
inlinestatic |
Calculate the actual dayOfMonth of the expresssion (onDayOfWeek >= onDayOfMonth).
The "last{dayOfWeek}" expression is expressed by onDayOfMonth being 0. An exact match on dayOfMonth is expressed by setting onDayOfWeek to 0.
Not private, used by ExtendedZoneSpecifier.
Definition at line 264 of file BasicZoneSpecifier.h.
|
inlineoverridevirtual |
Return the time zone abbreviation at epochSeconds.
This is an experimental method that has not been tested thoroughly. Use with caution. Returns an empty string ("") if an error occurs.
Implements ace_time::ZoneSpecifier.
Definition at line 173 of file BasicZoneSpecifier.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::ZoneSpecifier.
Definition at line 160 of file BasicZoneSpecifier.h.
|
inlineoverridevirtual |
The Transitions calculated by BasicZoneSpecifier contain only the epochSeconds when each transition occurs. They do not contain the local date/time components of the transition. This design reduces the amount of memory required by BasicZoneSpecifier, but this means that the information needed to implement this method correctly does not exist.
The implementation of this method is therefore a hack. First pass, we extract the TimeOffset on Jan 1 of the year given by the localDateTime, and guess its epochSeconds using that TimeOffset. Second pass, we use the epochSeconds from the previous pass to calculate the next best guess of the actual TimeOffset. We return the second pass guess as the result.
Implements ace_time::ZoneSpecifier.
Definition at line 193 of file BasicZoneSpecifier.h.
|
inlineoverridevirtual |
Return the total UTC offset at epochSeconds, including DST offset.
Returns TimeOffset::forError() if an error occurs.
Implements ace_time::ZoneSpecifier.
Definition at line 153 of file BasicZoneSpecifier.h.
|
inline |
Return the underlying ZoneInfo.
Definition at line 151 of file BasicZoneSpecifier.h.
|
inline |
Used only for debugging.
Definition at line 241 of file BasicZoneSpecifier.h.
|
overridevirtual |
Print the TD database zone identifier e.g "America/Los_Angeles".
Implements ace_time::ZoneSpecifier.
Definition at line 6 of file BasicZoneSpecifier.cpp.