-
-
Notifications
You must be signed in to change notification settings - Fork 127
FAQ #4
You have two choices that will both work. Either you can use this library to access the RTC device or you can used a modified version of this library that fully embraces the standard C time API.
It is simple to use the time_t type to retrieve and set the time. Just include time.h
and replace the RtcDateTime object you normally use with time_t and the method calls to modify it.
To get time just do this ...
time_t now = Rtc.GetDateTime();
and to set time just do this ...
time_t now; // initialize it how ever you want
Rtc.SetDateTime(now);
Now you can use the rest of the standard C time API with the time_t variable;
Instead of using this library, you can use the modified version of this library from here GitHub/Smz/Arduino-RTCtime. You can find it in the library manager as "RTCtime by smz".
This is very useful when you need to use a library that already uses the standard C time API or write code that needs to be compatible outside the Arduino ecosystem.