RTC lib

Added by ozzy over 6 years ago

Hi all.

Using the RTCLib is great, but how come that no one seems to want to what day of the week it is.
Working on some temperature control in our home, I have to know if its Saturday or Sunday.
The DateTime variable does not have the dayofweek in it. But there seems to be some dayofweek calculation in the library, I just cant find a way to use it.

Anyone out there have some good ideas ??


Replies (2)

RE: RTC lib - Added by martynj over 6 years ago


Doesn’t this entry point into RTClib provide what you need?

uint8_t DateTime::dayOfWeek() const {
    uint16_t day = get() / SECONDS_PER_DAY;
    return (day + 6) % 7; // Jan 1, 2000 is a Saturday, i.e. returns 6

RE: RTC lib - Added by ozzy over 6 years ago

That is the piece of code I found in the library. What I didn’t find was how to use it. But never mind, I did eventually find a solution.