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.
ZoneSpecifier.h
1 #ifndef ACE_TIME_ZONE_SPECIFIER_H
2 #define ACE_TIME_ZONE_SPECIFIER_H
3 
4 #include "common/common.h"
5 #include "TimeOffset.h"
6 #include "OffsetDateTime.h"
7 
8 class Print;
9 
10 namespace ace_time {
11 
12 class LocalDateTime;
13 
41  public:
43  static const uint8_t kTypeManual = 1;
44 
46  static const uint8_t kTypeBasic = 2;
47 
49  static const uint8_t kTypeExtended = 3;
50 
52  uint8_t getType() const { return mType; }
53 
58  virtual TimeOffset getUtcOffset(acetime_t epochSeconds) const = 0;
59 
65  virtual TimeOffset getDeltaOffset(acetime_t epochSeconds) const = 0;
66 
72  virtual const char* getAbbrev(acetime_t epochSeconds) const = 0;
73 
82  const = 0;
83 
85  virtual void printTo(Print& printer) const = 0;
86 
87  protected:
88  friend bool operator==(const ZoneSpecifier& a, const ZoneSpecifier& b);
89 
90  // Use default copy constructor and assignment operator.
91  ZoneSpecifier(const ZoneSpecifier&) = default;
92  ZoneSpecifier& operator=(const ZoneSpecifier&) = default;
93 
95  ZoneSpecifier(uint8_t type):
96  mType(type) {}
97 
99  virtual bool equals(const ZoneSpecifier& other) const = 0;
100 
101  uint8_t mType;
102 };
103 
104 inline bool operator==(const ZoneSpecifier& a, const ZoneSpecifier& b) {
105  if (a.getType() != b.getType()) return false;
106  return a.equals(b);
107 }
108 
109 inline bool operator!=(const ZoneSpecifier& a, const ZoneSpecifier& b) {
110  return ! (a == b);
111 }
112 
113 }
114 
115 #endif
virtual void printTo(Print &printer) const =0
Print a human-readable identifier.
virtual OffsetDateTime getOffsetDateTime(const LocalDateTime &ldt) const =0
Return the best estimate of the OffsetDateTime at the given LocalDateTime for the timezone of the cur...
uint8_t getType() const
Return the kTypeXxx of the current instance.
Definition: ZoneSpecifier.h:52
static const uint8_t kTypeBasic
Indicate BasicZoneSpecifier.
Definition: ZoneSpecifier.h:46
virtual TimeOffset getDeltaOffset(acetime_t epochSeconds) const =0
Return the DST delta offset at epochSeconds.
virtual bool equals(const ZoneSpecifier &other) const =0
Return true if equal.
Base interface for ZoneSpecifier classes.
Definition: ZoneSpecifier.h:40
static const uint8_t kTypeExtended
Indicate ExtendedZoneSpecifier.
Definition: ZoneSpecifier.h:49
The date (year, month, day) and time (hour, minute, second) fields representing the time with an offs...
ZoneSpecifier(uint8_t type)
Constructor.
Definition: ZoneSpecifier.h:95
static const uint8_t kTypeManual
Indicate ManualZoneSpecifier.
Definition: ZoneSpecifier.h:43
A thin wrapper that represents a time offset from a reference point, usually 00:00 at UTC...
Definition: TimeOffset.h:53
virtual TimeOffset getUtcOffset(acetime_t epochSeconds) const =0
Return the total UTC offset at epochSeconds, including DST offset.
virtual const char * getAbbrev(acetime_t epochSeconds) const =0
Return the time zone abbreviation at epochSeconds.