Skip to content

Commit

Permalink
Rename getRawTime to getEpochTime
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed Apr 15, 2016
1 parent b0776ef commit 9229123
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions NTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions NTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ getHours KEYWORD2
getMinutes KEYWORD2
getSeconds KEYWORD2
getFormattedTime KEYWORD2
getRawTime KEYWORD2
getEpochTime KEYWORD2

0 comments on commit 9229123

Please sign in to comment.