diff --git a/NTPClient.cpp b/NTPClient.cpp index 9ff8d86..075c7ba 100644 --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -101,27 +101,27 @@ bool NTPClient::update() { return true; } -unsigned long NTPClient::getRawTime() { +unsigned long NTPClient::getEpochTime() { return this->_timeOffset + // User offset this->_currentEpoc + // Epoc returned by the NTP server ((millis() - this->_lastUpdate) / 1000); // Time since last update } String NTPClient::getDay() { - return String(((this->getRawTime() / 86400L) + 4 ) % 7); //0 is Sunday + return String(((this->getEpochTime() / 86400L) + 4 ) % 7); //0 is Sunday } String NTPClient::getHours() { - return String((this->getRawTime() % 86400L) / 3600); + return String((this->getEpochTime() % 86400L) / 3600); } String NTPClient::getMinutes() { - return String((this->getRawTime() % 3600) / 60); + return String((this->getEpochTime() % 3600) / 60); } String NTPClient::getSeconds() { - return String(this->getRawTime() % 60); + return String(this->getEpochTime() % 60); } String NTPClient::getFormattedTime() { - unsigned long rawTime = this->getRawTime(); + unsigned long rawTime = this->getEpochTime(); unsigned long hours = (rawTime % 86400L) / 3600; String hoursStr = hours < 10 ? "0" + String(hours) : String(hours); diff --git a/NTPClient.h b/NTPClient.h index d1e25bf..8221329 100644 --- a/NTPClient.h +++ b/NTPClient.h @@ -69,9 +69,9 @@ class NTPClient { String getFormattedTime(); /** - * @return time as raw seconds + * @return time in seconds since Jan. 1, 1970 */ - unsigned long getRawTime(); + unsigned long getEpochTime(); /** * Stops the underlying UDP client diff --git a/keywords.txt b/keywords.txt index 0af987c..1430d04 100644 --- a/keywords.txt +++ b/keywords.txt @@ -17,4 +17,4 @@ getHours KEYWORD2 getMinutes KEYWORD2 getSeconds KEYWORD2 getFormattedTime KEYWORD2 -getRawTime KEYWORD2 +getEpochTime KEYWORD2