AceTime  0.6
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 
20 struct TimeZoneData {
21  static const uint8_t kTypeError = 0;
22  static const uint8_t kTypeManual = 1;
23  static const uint8_t kTypeZoneId = 2;
24 
25  uint8_t type;
26 
27  union {
29  struct {
30  int8_t stdOffsetCode;
31  int8_t dstOffsetCode;
32  };
33 
38  uint32_t zoneId;
39  };
40 };
41 
42 inline bool operator==(const TimeZoneData& a, const TimeZoneData& b) {
43  if (a.type != b.type) return false;
44  switch (a.type) {
45  case TimeZoneData::kTypeManual:
46  return (a.stdOffsetCode == b.stdOffsetCode)
47  && (a.dstOffsetCode == b.dstOffsetCode);
48  case TimeZoneData::kTypeZoneId:
49  return (a.zoneId == b.zoneId);
50  default:
51  return false;
52  }
53 }
54 
55 inline bool operator!=(const TimeZoneData& a, const TimeZoneData& b) {
56  return ! (a == b);
57 }
58 
59 }
60 
61 #endif
Data structure that captures the internal state of a TimeZone object with enough information so that ...
Definition: TimeZoneData.h:20
uint32_t zoneId
All of kTypeBasic, kTypeExtended, kTypeBasicManaged, kTypeExtendedManaged collapse down to a kTypeZon...
Definition: TimeZoneData.h:38