NTPClient
NTPClient copied to clipboard
Allow selecting time format
Today i needed formatted result only on HHmm, so i modified the get formatted metodhs. So if you agree it is a good idea create a new constructor whit a new argument passed for select some formatted result:
- HHmm
- HHmmss
- Etc.
I don't think adding time formatting to this library is a good idea. In my opinion any further time formatting should be done externally. The getFormattedTime() function is just to get you started.
I agree with @FWeinb on this.
If it doesn't exist already, a separate date formatting/parsing Arduino library would be ideal.
According to me I am missing: getMonth, getYear and getDay (not day of the week)
For general clock functions, I use the excellent https://github.com/PaulStoffregen/Time library and use NTP as a time sync provider.
#include "TimeLib.h"
time_t ntpSyncProvider() {
return timeClient.getEpochTime();
}
then:
setSyncProvider(&ntpSyncProvider);
That library does include an NTP example but I prefer using this NTPClient.