PaulStoffregen / Time

Time library for Arduino
http://playground.arduino.cc/code/time
1.26k stars 670 forks source link

Set system time so LittleFS can take over the real time #161

Open Andreotti100 opened 3 years ago

Andreotti100 commented 3 years ago

Using this library resulted in wrong file time stamps, 1970 style. So, I made a change:

#include // Needed for setting the right system time

void setTime(time_t t) {

ifdef TIME_DRIFT_INFO

if(sysUnsyncedTime == 0) sysUnsyncedTime = t; // store the time of the first call to set a valid Time

endif

sysTime = (uint32_t)t;
nextSyncTime = (uint32_t)t + syncInterval; Status = timeSet; prevMillis = millis(); // restart counting from now (thanks to Korman for this fix) *tune_timeshift64((uint64_t)sysTime 1000000ULL); // Take over the new time into the system time** }