AceTime  0.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.
HardwareDateTime.h
1 #ifndef ACE_TIME_HW_DATE_TIME_H
2 #define ACE_TIME_HW_DATE_TIME_H
3 
4 #if defined(ARDUINO)
5 
6 #include <stdint.h>
7 #include <Print.h> // Print
8 #include "../common/util.h"
9 
10 namespace ace_time {
11 namespace hw {
12 
17 struct HardwareDateTime {
19  void printTo(Print& printer) const;
20 
21  uint8_t year; // [00, 99], year - 2000
22  uint8_t month; // [1, 12]
23  uint8_t day; // [1, 31]
24  uint8_t hour; // [0, 23]
25  uint8_t minute; // [0, 59]
26  uint8_t second; // [0, 59]
27  uint8_t dayOfWeek; // [1, 7], interpretation undefined, increments every day
28 };
29 
35 inline bool operator==(const HardwareDateTime& a, const HardwareDateTime& b) {
36  return a.second == b.second
37  && a.minute == b.minute
38  && a.hour == b.hour
39  && a.day == b.day
40  && a.month == b.month
41  && a.year == b.year
42  && a.dayOfWeek == b.dayOfWeek;
43 }
44 
46 inline bool operator!=(const HardwareDateTime& a, const HardwareDateTime& b) {
47  return ! (a == b);
48 }
49 
50 }
51 }
52 
53 #endif
54 
55 #endif