AceTime  0.5.1
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 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_HW_DATE_TIME_H
7 #define ACE_TIME_HW_DATE_TIME_H
8 
9 #if defined(ARDUINO)
10 
11 #include <stdint.h>
12 #include <Print.h> // Print
13 #include "../common/util.h"
14 
15 namespace ace_time {
16 namespace hw {
17 
22 struct HardwareDateTime {
24  void printTo(Print& printer) const;
25 
26  uint8_t year; // [00, 99], year - 2000
27  uint8_t month; // [1, 12]
28  uint8_t day; // [1, 31]
29  uint8_t hour; // [0, 23]
30  uint8_t minute; // [0, 59]
31  uint8_t second; // [0, 59]
32  uint8_t dayOfWeek; // [1, 7], interpretation undefined, increments every day
33 };
34 
40 inline bool operator==(const HardwareDateTime& a, const HardwareDateTime& b) {
41  return a.second == b.second
42  && a.minute == b.minute
43  && a.hour == b.hour
44  && a.day == b.day
45  && a.month == b.month
46  && a.year == b.year
47  && a.dayOfWeek == b.dayOfWeek;
48 }
49 
51 inline bool operator!=(const HardwareDateTime& a, const HardwareDateTime& b) {
52  return ! (a == b);
53 }
54 
55 }
56 }
57 
58 #endif
59 
60 #endif