6 #ifndef ACE_TIME_TIME_ZONE_H
7 #define ACE_TIME_TIME_ZONE_H
10 #include "TimeOffset.h"
11 #include "ZoneProcessor.h"
12 #include "BasicZoneProcessor.h"
13 #include "ExtendedZoneProcessor.h"
14 #include "CompleteZoneProcessor.h"
15 #include "TimeZoneData.h"
16 #include "ZonedExtra.h"
119 return TimeZone(stdOffset, dstOffset);
180 (uintptr_t) zoneInfo,
199 (uintptr_t) zoneInfo,
218 (uintptr_t) zoneInfo,
248 mStdOffsetMinutes(0),
249 mDstOffsetMinutes(0) {}
279 return getBoundZoneProcessor()->
isLink();
296 return getBoundZoneProcessor()->
getZoneId();
315 abbrev = (mDstOffsetMinutes != 0) ?
"DST" :
"STD";
319 mStdOffsetMinutes * 60,
320 mDstOffsetMinutes * 60,
321 mStdOffsetMinutes * 60,
322 mDstOffsetMinutes * 60,
327 if (result.
type == FindResult::kTypeNotFound) {
353 abbrev = (mDstOffsetMinutes != 0) ?
"DST" :
"STD";
357 mStdOffsetMinutes * 60,
358 mDstOffsetMinutes * 60,
359 mStdOffsetMinutes * 60,
360 mDstOffsetMinutes * 60,
366 if (result.
type == FindResult::kTypeNotFound) {
401 if (result.
type == FindResult::kTypeNotFound) {
415 if (result.
type == FindResult::kTypeGap) {
448 if (result.
type == FindResult::kTypeNotFound) {
455 epochSeconds, offset, result.
fold);
465 return mStdOffsetMinutes == 0 && mDstOffsetMinutes == 0;
477 return mDstOffsetMinutes != 0;
491 d.type = TimeZoneData::kTypeError;
495 d.stdOffsetMinutes = mStdOffsetMinutes;
496 d.dstOffsetMinutes = mDstOffsetMinutes;
497 d.type = TimeZoneData::kTypeManual;
502 d.type = TimeZoneData::kTypeZoneId;
517 void printTo(Print& printer)
const;
560 mStdOffsetMinutes(stdOffset.toMinutes()),
561 mDstOffsetMinutes(dstOffset.toMinutes()) {}
579 ZoneProcessor* zoneProcessor
593 ZoneProcessor* getBoundZoneProcessor()
const {
608 int16_t mStdOffsetMinutes;
609 int16_t mDstOffsetMinutes;
636 inline bool operator==(
const TimeZone& a,
const TimeZone& b) {
637 if (a.mType != b.mType)
return false;
644 return a.mStdOffsetMinutes == b.mStdOffsetMinutes
645 && a.mDstOffsetMinutes == b.mDstOffsetMinutes;
648 return (a.mZoneKey == b.mZoneKey);
652 inline bool operator!=(
const TimeZone& a,
const TimeZone& b) {
A specific implementation of BasicZoneProcessorTemplate that uses ZoneXxxBrokers which read from zone...
A specific implementation of ExtendedZoneProcessorTemplate that uses the complete::ZoneXxxBrokers cla...
A specific implementation of ExtendedZoneProcessorTemplate that uses the extended::Info::ZoneXxxBroke...
Result of a search for transition at a specific epochSeconds or a specific LocalDateTime.
uint8_t fold
For findByLocalDateTime(), when type==kTypeOverlap, this is a copy of the requested LocalDateTime::fo...
int32_t stdOffsetSeconds
STD offset of the resulting OffsetDateTime.
int32_t dstOffsetSeconds
DST offset of the resulting OffsetDateTime.
int32_t reqDstOffsetSeconds
DST offset of the Transition which matched the epochSeconds requested by findByEpochSeconds(),...
const char * abbrev
Pointer to the abbreviation stored in the transient Transition::abbrev variable.
int32_t reqStdOffsetSeconds
STD offset of the Transition which matched the epochSeconds requested by findByEpochSeconds(),...
uint8_t type
Result of the findByEpochSeconds() or findByLocalDateTime() search methods.
Class that holds the date-time as the components (year, month, day, hour, minute, second) without reg...
The date (year, month, day), time (hour, minute, second) and fixed offset from UTC (timeOffset).
static OffsetDateTime forLocalDateTimeAndOffset(const LocalDateTime &localDateTime, TimeOffset timeOffset)
Factory method from LocalDateTime and TimeOffset.
acetime_t toEpochSeconds() const
Return seconds since AceTime epoch taking into account the UTC offset.
static OffsetDateTime forError()
Factory method that returns an instance whose isError() is true.
uint8_t fold() const
Return the fold.
static OffsetDateTime forEpochSeconds(acetime_t epochSeconds, TimeOffset timeOffset, uint8_t fold=0)
Factory method.
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC,...
static TimeOffset forSeconds(int32_t seconds)
Create TimeOffset from seconds from 00:00.
static TimeOffset forHours(int8_t hours)
Create TimeOffset with the corresponding hour offset.
static TimeOffset forHourMinute(int8_t hour, int8_t minute)
Create TimeOffset from (hour, minute) offset.
static TimeOffset forMinutes(int16_t minutes)
Create TimeOffset from minutes from 00:00.
Class that describes a time zone.
ZonedExtra getZonedExtra(acetime_t epochSeconds) const
Return the ZonedExtra information at epochSeconds.
static TimeZone forZoneInfo(const complete::Info::ZoneInfo *zoneInfo, CompleteZoneProcessor *zoneProcessor)
Convenience factory method to create from a zoneInfo and an associated ExtendedZoneProcessor.
void printTo(Print &printer) const
Print the text representation of the time zone using the full canonical time zone name or UTC offset ...
uint32_t getZoneId() const
Return the zoneId for kTypeBasic, kTypeExtended.
ZoneProcessor * mZoneProcessor
An instance of a ZoneProcessor, for example, BasicZoneProcessor or ExtendedZoneProcessor.
static TimeZone forZoneInfo(const basic::Info::ZoneInfo *zoneInfo, BasicZoneProcessor *zoneProcessor)
Convenience factory method to create from a zoneInfo and an associated BasicZoneProcessor.
void printTargetNameTo(Print &printer) const
Print the name of the target zone if the current time zone is a Link.
static TimeZone forZoneInfo(const extended::Info::ZoneInfo *zoneInfo, ExtendedZoneProcessor *zoneProcessor)
Convenience factory method to create from a zoneInfo and an associated ExtendedZoneProcessor.
OffsetDateTime getOffsetDateTime(const LocalDateTime &ldt) const
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the current TimeZone.
OffsetDateTime getOffsetDateTime(acetime_t epochSeconds) const
Return the best estimate of the OffsetDateTime at the given epochSeconds.
bool isUtc() const
Return true if UTC (+00:00+00:00).
static TimeZone forUtc()
Factory method to create a UTC TimeZone.
static TimeZone forHours(int8_t stdHours, int8_t dstHours=0)
Factory method to create from UTC hour offset and optional DST hour offset.
uint8_t getType() const
Return the type of TimeZone, used to determine the behavior of certain methods at runtime.
bool isLink() const
Return true if timezone is a Link entry pointing to a Zone entry.
uintptr_t mZoneKey
An opaque zone key.
static TimeZone forMinutes(int16_t stdMinutes, int16_t dstMinutes=0)
Factory method to create from UTC minute offset and optional DST minute offset.
void printShortTo(Print &printer) const
Print the short human readable representation of the time zone.
static const uint8_t kTypeError
A TimeZone that represents an invalid condition.
static TimeZone forError()
Return a TimeZone representing an error condition.
static TimeZone forZoneKey(uintptr_t zoneKey, ZoneProcessor *processor)
Factory method to create from a generic zoneKey and a generic zoneProcessor.
TimeOffset getDstOffset() const
Return the DST TimeOffset.
bool isError() const
Return true if TimeZone is an error.
bool isDst() const
Return if mDstOffsetMinutes is not zero.
static TimeZone forTimeOffset(TimeOffset stdOffset, TimeOffset dstOffset=TimeOffset())
Factory method to create from a UTC offset and an optional DST offset.
static const uint8_t kTypeReserved
Reserved for future use.
ZonedExtra getZonedExtra(const LocalDateTime &ldt) const
Return the ZonedExtra information at epochSeconds.
static TimeZone forHourMinute(int8_t stdHour, int8_t stdMinute, int8_t dstHour=0, int8_t dstMinute=0)
Factory method to create from UTC (hour, minute) pair and optional DST (hour, minute) pair.
TimeZoneData toTimeZoneData() const
Convert to a TimeZoneData object, which can be fed back into ZoneManager::createForTimeZoneData() to ...
TimeOffset getStdOffset() const
Return the Standard TimeOffset.
static const uint8_t kTypeManual
Manual STD offset and DST offset.
TimeZone()
Default constructor creates a UTC TimeZone.
Base interface for ZoneProcessor classes.
uint8_t getType() const
Return the kTypeXxx of the current instance.
virtual FindResult findByEpochSeconds(acetime_t epochSeconds) const =0
Return the search results at given epochSeconds.
virtual uint32_t getZoneId() const =0
Return the unique stable zoneId.
virtual FindResult findByLocalDateTime(const LocalDateTime &ldt) const =0
Return the search results at given LocalDateTime.
virtual bool isLink() const =0
Return true if timezone is a Link entry pointing to a Zone entry.
virtual void setZoneKey(uintptr_t zoneKey)=0
Set the opaque zoneKey of this object to a new value, reseting any internally cached information.
int32_t acetime_t
Type for the number of seconds from epoch.
Data structure that captures the internal state of a TimeZone object with enough information so that ...
uint32_t zoneId
Both TimeZone::kTypeBasic and TimeZone::kTypeExtended are mapped to a TimeZoneData::kTypeZoneId.
Representation of a given time zone, implemented as an array of ZoneEra records.
Representation of a given time zone, implemented as an array of ZoneEra records.