PaulStoffregen / Time

Time library for Arduino

Home Page:http://playground.arduino.cc/code/time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nextSyncTime calculation is not correctly positionned

pierre83 opened this issue · comments

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 }

is calculated in setTime()