PaulStoffregen / Time

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

nextSyncTime calculation is not correctly positionned #137

Closed pierre83 closed 4 years ago

pierre83 commented 4 years ago

In time.cpp: 260 if (nextSyncTime <= sysTime) { 261 if (getTimePtr != 0) { 262 time_t t = getTimePtr(); 263 if (t != 0) { 264 setTime(t); 265 } else { 266 nextSyncTime = sysTime + syncInterval; 267 Status = (Status == timeNotSet) ? timeNotSet : timeNeedsSync; // **** 268 } 269 } 270 } Should be:

And, for me, the best should be: 260 if (getTimePtr != 0) { // Should be faster 261 if (nextSyncTime <= sysTime) { 262 time_t t = getTimePtr(); 263 if (t != 0) { 264 setTime(t); 265 } else { 266 Status = (Status == timeNotSet) ? timeNotSet 267 } 268 nextSyncTime = sysTime + syncInterval;: timeNeedsSync; // **** 269 } 270 }

pierre83 commented 4 years ago

is calculated in setTime()