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.
BasicZone.h
1 /*
2  * MIT License
3  * Copyright (c) 2019 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_BASIC_ZONE_H
7 #define ACE_TIME_BASIC_ZONE_H
8 
9 #include "internal/ZoneInfo.h"
10 #include "internal/Brokers.h"
11 #include "common/compat.h"
12 
13 class __FlashStringHelper;
14 
15 namespace ace_time {
16 
22 class BasicZone {
23  public:
24  BasicZone(const basic::ZoneInfo* zoneInfo):
25  mZoneInfoBroker(zoneInfo) {}
26 
27 // TODO: Merge this with ExtendedZone.h now that they both use the same
28 // ACE_TIME_USE_PROGMEM macro.
29 #if ACE_TIME_USE_PROGMEM
30  const __FlashStringHelper* name() const {
31  return (const __FlashStringHelper*) mZoneInfoBroker.name();
32  }
33 
34  const __FlashStringHelper* shortName() const {
35  const char* name = mZoneInfoBroker.name();
36  const char* slash = strrchr_P(name, '/');
37  return (slash) ? (const __FlashStringHelper*) (slash + 1)
38  : (const __FlashStringHelper*) name;
39  }
40 #else
41  const char* name() const {
42  return (const char*) mZoneInfoBroker.name();
43  }
44 
45  const char* shortName() const {
46  const char* name = mZoneInfoBroker.name();
47  const char* slash = strrchr(name, '/');
48  return (slash) ? (slash + 1) : name;
49  }
50 #endif
51 
52  uint32_t zoneId() const {
53  return mZoneInfoBroker.zoneId();
54  }
55 
56  private:
57  // disable default copy constructor and assignment operator
58  BasicZone(const BasicZone&) = delete;
59  BasicZone& operator=(const BasicZone&) = delete;
60 
61  const basic::ZoneInfoBroker mZoneInfoBroker;
62 };
63 
64 }
65 
66 #endif
Brokers.h
ace_time::BasicZone
A thin wrapper around a basic::ZoneInfo data structure to provide a stable API access to some useful ...
Definition: BasicZone.h:22
compat.h
ace_time::basic::ZoneInfoBroker
Data broker for accessing ZoneInfo.
Definition: Brokers.h:306