NTPClient
NTPClient copied to clipboard
Using getFormattedTime() to format a given time
I've adjusted getFormattedTime() to take an (optional) 'secs' argument, so that the same formatting code can be used to format any given time, while still formatting the NTP time if the argument is left out. This is similar to time conversion functions in other languages, and might avoid the need to include a dedicated time/date library in some projects.
NTPClient.h:
/**
* @return secs argument (or 0 for current time) formatted like `hh:mm:ss`
*/
String getFormattedTime(unsigned long secs = 0);
NTPClient.cpp:
String NTPClient::getFormattedTime(unsigned long secs) {
unsigned long rawTime = secs ? secs : this->getEpochTime();
This is great! I was suprised to realize that this simple function wasn't pulled so far? I'm using the frok from @taranais now! kudos
Hi @sheffieldnikki. Thanks for taking the time to submit an issue.
I see we have another report about this at https://github.com/arduino-libraries/NTPClient/issues/3.
It is best to have only a single issue per subject so we can consolidate all relevant discussion to one place, so I'll go ahead and close this in favor of the other.
If you end up with additional information to share, feel free to comment in the other thread.