DS1307RTC library invalid date

I'm using the DS1307RTC library from this site: DS1307RTC Library, For Accessing Real Time Clock (RTC) Chips

I was wondering what would RTC.write(tm) return if you wrote an invalid value into it. For example, if I set tm.Day = 31 and tm.Month = 2, which is February 31, and then use RTC.write(tm), would it return a false value? Thanks in advance! :slight_smile:

The value returned by RTC.write() indicates success of the I2C communication. So as long as an RTC is present and properly connected, I would expect it to return true.

If it were me, I might answer my own question and just try it, there's no harm in that.

Note that the DS1307 datasheet says, "Illogical time and date entries result in undefined operation."

Thanks. I converted tm(tmElement_t) to t(time_t) variable instead coz it says in the Time library of Time Library, Timekeeping and Time/Date Manipulation on Teensy that "Using time_t lets you store or compare times as a single number, rather that dealing with 6 numbers and details like the number of days in each month and leap years."

So I replaced the "If (!RTC.write(tm))" part of my code with "if (!RTC.set(makeTime(tm)))" and it compiled just fine. I hope it works. Thanks again! :slight_smile: