Skip to content

Rename getRawTime to getEpochTime #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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