From 28f1212a3e47a624f0dff07c2c88a686b349dbfa Mon Sep 17 00:00:00 2001 From: Hasenradball Date: Tue, 17 Oct 2023 07:32:37 +0200 Subject: [PATCH 1/3] Update DS3231.h - reorder protected members to be able to use member initializer. --- DS3231.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DS3231.h b/DS3231.h index 6f27495..155f7d4 100644 --- a/DS3231.h +++ b/DS3231.h @@ -52,7 +52,7 @@ class DateTime { // SETTING YOUR CLOCK TO UTC uint32_t unixtime(void) const; protected: - uint8_t yOff, m, d, hh, mm, ss; + uint8_t ss, mm, hh, d, m, yOff; }; // Checks if a year is a leap year From 46472aeac5a0ce2105d3237b0fa03d8b8f4d045c Mon Sep 17 00:00:00 2001 From: Hasenradball Date: Tue, 17 Oct 2023 07:40:13 +0200 Subject: [PATCH 2/3] Update DS3231.cpp - improve initialising of members using member-initializerlist --- DS3231.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/DS3231.cpp b/DS3231.cpp index 79a973a..1905435 100644 --- a/DS3231.cpp +++ b/DS3231.cpp @@ -121,15 +121,13 @@ DateTime::DateTime (uint32_t t) { d = days + 1; } -DateTime::DateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) { - if (year >= 2000) +DateTime::DateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) +: ss {sec}, mm {min}, hh = {hour}, d {day}, m {month} +{ + if (year >= 2000) { year -= 2000; + } yOff = year; - m = month; - d = day; - hh = hour; - mm = min; - ss = sec; } // supported formats are date "Mmm dd yyyy" and time "hh:mm:ss" (same as __DATE__ and __TIME__) From ed9443ae2c4933194ee063971c0291097540525f Mon Sep 17 00:00:00 2001 From: Hasenradball Date: Tue, 17 Oct 2023 07:46:12 +0200 Subject: [PATCH 3/3] Update DS3231.cpp - small typo --- DS3231.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DS3231.cpp b/DS3231.cpp index 1905435..fdb87a7 100644 --- a/DS3231.cpp +++ b/DS3231.cpp @@ -122,7 +122,7 @@ DateTime::DateTime (uint32_t t) { } DateTime::DateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) -: ss {sec}, mm {min}, hh = {hour}, d {day}, m {month} +: ss {sec}, mm {min}, hh {hour}, d {day}, m {month} { if (year >= 2000) { year -= 2000;