Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DS3231]: Constructor improvement #92

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions DS3231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion DS3231.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down