diff --git a/NTPClient.cpp b/NTPClient.cpp index b435855..cc1f006 100755 --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -148,6 +148,19 @@ int NTPClient::getMinutes() const { int NTPClient::getSeconds() const { return (this->getEpochTime() % 60); } +// functions for decode extern epoch time +int NTPClient::getDay(unsigned long epochTime) const { + return (((epochTime / 86400L) + 4 ) % 7); //0 is Sunday +} +int NTPClient::getHours(unsigned long epochTime) const { + return ((epochTime % 86400L) / 3600); +} +int NTPClient::getMinutes(unsigned long epochTime) const { + return ((epochTime % 3600) / 60); +} +int NTPClient::getSeconds(unsigned long epochTime) const { + return (epochTime % 60); +} String NTPClient::getFormattedTime() const { unsigned long rawTime = this->getEpochTime(); diff --git a/NTPClient.h b/NTPClient.h index a31d32f..8df5321 100755 --- a/NTPClient.h +++ b/NTPClient.h @@ -85,7 +85,11 @@ class NTPClient { int getHours() const; int getMinutes() const; int getSeconds() const; - + int getDay(unsigned long epochTime) const; + int getHours(unsigned long epochTime) const; + int getMinutes(unsigned long epochTime) const; + int getSeconds(unsigned long epochTime) const; + /** * Changes the time offset. Useful for changing timezones dynamically */