Merge pull request #7 from pnewb/master

Adding support for getting numerical day of the week where 0 = Sunday
This commit is contained in:
FWeinb 2016-03-31 12:24:50 +02:00
commit 056b9b4110
3 changed files with 6 additions and 2 deletions

View File

@ -89,13 +89,15 @@ unsigned long NTPClient::getRawTime() {
((millis() - this->_lastUpdate) / 1000); // Time since last update ((millis() - this->_lastUpdate) / 1000); // Time since last update
} }
String NTPClient::getDay() {
return String(((this->getRawTime() / 86400L) + 4 ) % 7); //0 is Sunday
}
String NTPClient::getHours() { String NTPClient::getHours() {
return String((this->getRawTime() % 86400L) / 3600); return String((this->getRawTime() % 86400L) / 3600);
} }
String NTPClient::getMinutes() { String NTPClient::getMinutes() {
return String((this->getRawTime() % 3600) / 60); return String((this->getRawTime() % 3600) / 60);
} }
String NTPClient::getSeconds() { String NTPClient::getSeconds() {
return String(this->getRawTime() % 60); return String(this->getRawTime() % 60);
} }

View File

@ -43,6 +43,7 @@ class NTPClient {
*/ */
void forceUpdate(); void forceUpdate();
String getDay();
String getHours(); String getHours();
String getMinutes(); String getMinutes();
String getSeconds(); String getSeconds();

View File

@ -11,8 +11,9 @@ NTPClient KEYWORD1
begin KEYWORD2 begin KEYWORD2
update KEYWORD2 update KEYWORD2
forceUpdate KEYWORD2 forceUpdate KEYWORD2
getDay KEYWORD2
getHours KEYWORD2 getHours KEYWORD2
getMinutes KEYWORD2 getMinutes KEYWORD2
getSeconds KEYWORD2 getSeconds KEYWORD2
getFormattedTime KEYWORD2 getFormattedTime KEYWORD2
getRawTime KEYWORD2 getRawTime KEYWORD2