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.
TimeZoneData.h
1 /*
2  * MIT License
3  * Copyright (c) 2019 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_TIME_ZONE_DATA_H
7 #define ACE_TIME_TIME_ZONE_DATA_H
8 
9 #include <stdint.h>
10 #include "ZoneProcessor.h"
11 
12 namespace ace_time {
13 
27 struct TimeZoneData {
28  static const uint8_t kTypeError = 0;
29  static const uint8_t kTypeManual = 1;
30  static const uint8_t kTypeZoneId = 2;
31 
32  uint8_t type;
33 
34  union {
36  struct {
37  int16_t stdOffsetMinutes;
38  int16_t dstOffsetMinutes;
39  };
40 
45  uint32_t zoneId;
46  };
47 };
48 
49 inline bool operator==(const TimeZoneData& a, const TimeZoneData& b) {
50  if (a.type != b.type) return false;
51  switch (a.type) {
52  case TimeZoneData::kTypeManual:
53  return (a.stdOffsetMinutes == b.stdOffsetMinutes)
54  && (a.dstOffsetMinutes == b.dstOffsetMinutes);
55  case TimeZoneData::kTypeZoneId:
56  return (a.zoneId == b.zoneId);
57  default:
58  return false;
59  }
60 }
61 
62 inline bool operator!=(const TimeZoneData& a, const TimeZoneData& b) {
63  return ! (a == b);
64 }
65 
66 }
67 
68 #endif
Data structure that captures the internal state of a TimeZone object with enough information so that ...
Definition: TimeZoneData.h:27
uint32_t zoneId
All of kTypeBasic, kTypeExtended, kTypeBasicManaged, kTypeExtendedManaged collapse down to a kTypeZon...
Definition: TimeZoneData.h:45