AceTime  0.1
Date and time classes for Arduino that supports the TZ DAtabase, and a system clock synchronized 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 
7 class Print;
8 
9 namespace ace_time {
10 
11 class LocalDateTime;
12 
40  public:
42  static const uint8_t kTypeManual = 1;
43 
45  static const uint8_t kTypeBasic = 2;
46 
48  static const uint8_t kTypeExtended = 3;
49 
51  uint8_t getType() const { return mType; }
52 
54  virtual TimeOffset getUtcOffset(acetime_t epochSeconds) const = 0;
55 
60  virtual TimeOffset getDeltaOffset(acetime_t epochSeconds) const = 0;
61 
67  virtual const char* getAbbrev(acetime_t epochSeconds) const = 0;
68 
71  const = 0;
72 
74  virtual void printTo(Print& printer) const = 0;
75 
76  protected:
77  friend bool operator==(const ZoneSpecifier& a, const ZoneSpecifier& b);
78 
79  // Use default copy constructor and assignment operator.
80  ZoneSpecifier(const ZoneSpecifier&) = default;
81  ZoneSpecifier& operator=(const ZoneSpecifier&) = default;
82 
84  ZoneSpecifier(uint8_t type):
85  mType(type) {}
86 
88  virtual bool equals(const ZoneSpecifier& other) const = 0;
89 
90  uint8_t mType;
91 };
92 
93 inline bool operator==(const ZoneSpecifier& a, const ZoneSpecifier& b) {
94  if (a.getType() != b.getType()) return false;
95  return a.equals(b);
96 }
97 
98 inline bool operator!=(const ZoneSpecifier& a, const ZoneSpecifier& b) {
99  return ! (a == b);
100 }
101 
102 }
103 
104 #endif
virtual void printTo(Print &printer) const =0
Print a human-readable identifier.
static const uint8_t kTypeBasic
Indicate BasicZoneSpecifier.
Definition: ZoneSpecifier.h:45
virtual TimeOffset getUtcOffsetForDateTime(const LocalDateTime &ldt) const =0
Return the UTC offset matching the given the date/time components.
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:39
uint8_t getType() const
Return the kTypeXxx of the current instance.
Definition: ZoneSpecifier.h:51
static const uint8_t kTypeExtended
Indicate ExtendedZoneSpecifier.
Definition: ZoneSpecifier.h:48
ZoneSpecifier(uint8_t type)
Constructor.
Definition: ZoneSpecifier.h:84
static const uint8_t kTypeManual
Indicate ManualZoneSpecifier.
Definition: ZoneSpecifier.h:42
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.