AceTime  0.7
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.
ExtendedZone.h
1 /*
2  * MIT License
3  * Copyright (c) 2019 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_EXTENDED_ZONE_H
7 #define ACE_TIME_EXTENDED_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 
23 class ExtendedZone {
24  public:
25  ExtendedZone(const extended::ZoneInfo* zoneInfo):
26  mZoneInfoBroker(zoneInfo) {}
27 
28  // use default copy constructor and assignment operator
29  ExtendedZone(const ExtendedZone&) = default;
30  ExtendedZone& operator=(const ExtendedZone&) = default;
31 
32 // TODO: Merge this with BasicZone.h now that they both use the same
33 // ACE_TIME_USE_PROGMEM macro.
34 #if ACE_TIME_USE_PROGMEM
35  const __FlashStringHelper* name() const {
36  return (const __FlashStringHelper*) mZoneInfoBroker.name();
37  }
38 
39  const __FlashStringHelper* shortName() const {
40  const char* name = mZoneInfoBroker.name();
41  const char* slash = strrchr_P(name, '/');
42  return (slash) ? (const __FlashStringHelper*) (slash + 1)
43  : (const __FlashStringHelper*) name;
44  }
45 #else
46  const char* name() const {
47  return mZoneInfoBroker.name();
48  }
49 
50  const char* shortName() const {
51  const char* name = mZoneInfoBroker.name();
52  const char* slash = strrchr(name, '/');
53  return (slash) ? (slash + 1) : name;
54  }
55 #endif
56 
57  uint32_t zoneId() const {
58  return mZoneInfoBroker.zoneId();
59  }
60 
61  private:
62  const extended::ZoneInfoBroker mZoneInfoBroker;
63 };
64 
65 }
66 
67 #endif
Representation of a given time zone, implemented as an array of ZoneEra records.
Definition: ZoneInfo.h:86
A thin wrapper around an extended::ZoneInfo data structure to provide a stable API access to some use...
Definition: ExtendedZone.h:23
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...