AceTime
1.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.
|
6 #ifndef ACE_TIME_ZONE_MANAGER_H
7 #define ACE_TIME_ZONE_MANAGER_H
9 #include "ZoneProcessorCache.h"
10 #include "ZoneRegistrar.h"
11 #include "TimeZoneData.h"
93 case TimeZone::kTypeError:
95 case TimeZone::kTypeManual:
137 template<
typename ZI,
typename ZR,
typename ZSC>
138 class ZoneManagerImpl :
public ZoneManager {
140 TimeZone createForZoneName(
const char* name)
override {
141 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForName(name);
145 TimeZone createForZoneId(uint32_t
id)
override {
146 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForId(
id);
150 TimeZone createForZoneIndex(uint16_t index)
override {
151 const ZI* zoneInfo = mZoneRegistrar.getZoneInfoForIndex(index);
155 TimeZone createForTimeZoneData(
const TimeZoneData& d)
override {
157 case TimeZone::kTypeError:
159 case TimeZone::kTypeManual:
163 case TimeZone::kTypeBasic:
164 case TimeZone::kTypeExtended:
165 return createForZoneId(d.zoneId);
172 uint16_t indexForZoneName(
const char* name)
const override {
173 return mZoneRegistrar.findIndexForName(name);
176 uint16_t indexForZoneId(uint32_t
id)
const override {
177 return mZoneRegistrar.findIndexForId(
id);
180 uint16_t registrySize()
const override {
181 return mZoneRegistrar.registrySize();
192 return TimeZone(zoneInfo, &mZoneProcessorCache);
203 mZoneRegistrar(registrySize, zoneRegistry),
204 mZoneProcessorCache() {}
211 const ZR mZoneRegistrar;
212 ZSC mZoneProcessorCache;
222 template<u
int16_t SIZE>
224 BasicZoneRegistrar, BasicZoneProcessorCache<SIZE>> {
227 const basic::ZoneInfo*
const* zoneRegistry):
238 template<u
int16_t SIZE>
240 ExtendedZoneRegistrar, ExtendedZoneProcessorCache<SIZE>> {
243 const extended::ZoneInfo*
const* zoneRegistry):
256 template<u
int8_t SIZE>
260 template<u
int8_t SIZE>
TimeZone createForZoneId(uint32_t) override
Create a TimeZone for the given 32-bit zoneId.
ZoneManagerImpl(uint16_t registrySize, const ZI *const *zoneRegistry)
Constructor.
A ZoneManager that implements only createForTimeZoneData() to create TimeZones of type kTypeManual,...
uint16_t indexForZoneName(const char *) const override
Find the registry index for the given time zone name.
static TimeZone forError()
Return a TimeZone representing an error condition.
TimeZone createForZoneInfo(const ZI *zoneInfo)
Create a TimeZone from an explicit ZoneInfo reference.
virtual uint16_t indexForZoneName(const char *name) const =0
Find the registry index for the given time zone name.
Class that allows looking up the ZoneInfo (ZI) from its TZDB identifier (e.g.
virtual TimeZone createForZoneId(uint32_t id)=0
Create a TimeZone for the given 32-bit zoneId.
An implementation of the ZoneManager which uses a registry of basic::ZoneInfo records.
static const uint16_t kInvalidIndex
Registry index which is not valid.
static TimeOffset forMinutes(int16_t minutes)
Create TimeOffset from minutes from 00:00.
virtual uint16_t indexForZoneId(uint32_t id) const =0
Find the registry index for the given time zone id.
virtual TimeZone createForZoneIndex(uint16_t index)=0
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
virtual uint16_t registrySize() const =0
Return the number of elements in the registry.
uint16_t registrySize() const override
Return the number of elements in the registry.
Common interface to the BasicZoneManager and ExtendedZoneManager so that a single interface can be pa...
Data structure that captures the internal state of a TimeZone object with enough information so that ...
TimeZone createForZoneIndex(uint16_t) override
Create a TimeZone for the given index in the ZoneInfo registry that was used to create this ZoneManag...
TimeZone createForTimeZoneData(const TimeZoneData &d) override
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
An implementation of the ZoneManager which uses a registry of extended::ZoneInfo records.
A templatized implementation of ZoneManager that binds the (Basic|Extended)ZoneRegistrar with the cor...
Class that describes a time zone.
static TimeZone forTimeOffset(TimeOffset stdOffset, TimeOffset dstOffset=TimeOffset())
Factory method to create from a UTC offset and an optional DST offset.
virtual TimeZone createForTimeZoneData(const TimeZoneData &d)=0
Create a TimeZone from the TimeZoneData created by TimeZone::toTimeZoneData().
uint16_t indexForZoneId(uint32_t) const override
Find the registry index for the given time zone id.
virtual TimeZone createForZoneName(const char *name)=0
Create a TimeZone for the given zone name (e.g.
TimeZone createForZoneName(const char *) override
Create a TimeZone for the given zone name (e.g.