Question regarding the TimeLib library

Dear Sirs,
is there an easy on demand way to do what the command ex
For the needs of my project I need to “manual activate/initiate” this sync on demand regardless of the above command.

Any way to do this? Any help?

Thanks and Best Regards,
Mike Kranidis

Just call syncVirtual on the widget virtual pin

Dear vhymanskyy,

Thanks a lot for your answer but I am not sure that I understood.
I want to be able to synchronize the time on my ESP8266 ( the time is getting from NTP server ).
Because I am writing my own routine for auto timezone adjustment ( DST … ) I need a way when I calculate the correct timezone then to synchronize the time getting the new timezone in to consideration. That’s why I need a manual way to initiate something like setSyncInterval(now) .

That is!

P.S. I don’t want to use blynk RTC and TimeInput timezone for some reasons

Why don’t you want to use those libraries? They work perfectly fine, even with DST.

I’ve made a routine which checks if the year is 1970 and sets a low value on syncInterval and if the year is no longer 1970, it sets a longer interval to prevent flooding and such. Maybe you can apply some of that logic with a flag that you can set to initiate a short interval? E.g. if flag0 = 1, setSyncinterval(lowvalue) otherwise, set it to 300 or something.

Dear Lichtsignaal,

thanks a lot for your answer. I have done this in a similar way.
I develop a project that can be work without blynk and for this reason I am looking for a sane way to initiate re-sync without changing the setSyncInterval(nn) nn value.
I tried to see/follow how TimeLib implement this sync in order to gain access to the particular function that does the actual sync ( because the logic says that check the nn time and when it is passed a function call back will be performed ) but without success, I am not good in C / C++.

Anyway, again I thank you for your nice suggestion.

Best Regards,
Mike Kranidis

To answer my question, see:
A fine way to achieve the requested above ( as Mr, blackketter suggested me @ ), just a call to setSyncProvider() with our time function, initiate the sync line “syncNow”… In my case, just a call to: setSyncProvider(getNtpTime);
do the trick.
Problem solved!

Thanks very much for reporting back with this! I myself can use it, lol.

I made a little variation on the theme I suggested. This day and age I set a very low value for interval in Setup(). Then with a timer I check if the year does not equal 1970 anymore and then I set the interval much bigger. Also works fine :slight_smile:

Dear friend,
Just keep in mind that time lib also provide a way to tell you if there is correct time or not, just try something like:
timeStatus() == timeNotSet

That did the trick…!

Best Regards,
Mike Kranidis