AceTimeClock  1.3.0
Clock classes for Arduino 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 #include <stdint.h>
10 #include <Print.h> // Print
11 
12 namespace ace_time {
13 namespace hw {
14 
20  public:
22  static const int16_t kBaseYear = 2000;
23 
25  void printTo(Print& printer) const;
26 
28  uint8_t year;
29 
31  uint8_t month;
32 
34  uint8_t day;
35 
37  uint8_t hour;
38 
40  uint8_t minute;
41 
43  uint8_t second;
44 
46  uint8_t dayOfWeek;
47 };
48 
54 inline bool operator==(const HardwareDateTime& a, const HardwareDateTime& b) {
55  return a.second == b.second
56  && a.minute == b.minute
57  && a.hour == b.hour
58  && a.day == b.day
59  && a.month == b.month
60  && a.year == b.year
61  && a.dayOfWeek == b.dayOfWeek;
62 }
63 
65 inline bool operator!=(const HardwareDateTime& a, const HardwareDateTime& b) {
66  return ! (a == b);
67 }
68 
69 }
70 }
71 
72 #endif
The date (year, month, day) and time (hour, minute, second) fields supported by the DS3231 RTC chip.
static const int16_t kBaseYear
Base year of the DS3231 chip.
uint8_t year
[00, 99], year - 2000
uint8_t dayOfWeek
[1, 7], interpretation undefined, increments every day
void printTo(Print &printer) const
Print HardwareDateTime to 'printer'.