AceTime  0.8
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  // use default copy constructor and assignment operator
28  BasicZone(const BasicZone&) = default;
29  BasicZone& operator=(const BasicZone&) = default;
30 
31 // TODO: Merge this with ExtendedZone.h now that they both use the same
32 // ACE_TIME_USE_PROGMEM macro.
33 #if ACE_TIME_USE_PROGMEM
34  const __FlashStringHelper* name() const {
35  return (const __FlashStringHelper*) mZoneInfoBroker.name();
36  }
37 
38  const __FlashStringHelper* shortName() const {
39  const char* name = mZoneInfoBroker.name();
40  const char* slash = strrchr_P(name, '/');
41  return (slash) ? (const __FlashStringHelper*) (slash + 1)
42  : (const __FlashStringHelper*) name;
43  }
44 #else
45  const char* name() const {
46  return (const char*) mZoneInfoBroker.name();
47  }
48 
49  const char* shortName() const {
50  const char* name = mZoneInfoBroker.name();
51  const char* slash = strrchr(name, '/');
52  return (slash) ? (slash + 1) : name;
53  }
54 #endif
55 
56  uint32_t zoneId() const {
57  return mZoneInfoBroker.zoneId();
58  }
59 
60  private:
61  const basic::ZoneInfoBroker mZoneInfoBroker;
62 };
63 
64 }
65 
66 #endif
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfo.h:100
A thin wrapper around a basic::ZoneInfo data structure to provide a stable API access to some useful ...
Definition: BasicZone.h:22
The classes provide a thin layer of indirection for accessing the zoneinfo files stored in the zonedb...
Macros and definitions that provide a consistency layer among the various Arduino boards for compatib...
Data broker for accessing ZoneInfo.
Definition: Brokers.h:312