Skip to content

Commit 846351c

Browse files
committed
Adding support for getting numerical day of the week where 0 = Sunday
1 parent 705ca02 commit 846351c

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

NTPClient.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ unsigned long NTPClient::getRawTime() {
8989
((millis() - this->_lastUpdate) / 1000); // Time since last update
9090
}
9191

92+
String NTPClient::getDay() {
93+
return String(((this->getRawTime() / 86400L) + 4 ) % 7); //0 is Sunday
94+
}
9295
String NTPClient::getHours() {
9396
return String((this->getRawTime() % 86400L) / 3600);
9497
}
9598
String NTPClient::getMinutes() {
9699
return String((this->getRawTime() % 3600) / 60);
97100
}
98-
99101
String NTPClient::getSeconds() {
100102
return String(this->getRawTime() % 60);
101103
}

NTPClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class NTPClient {
4343
*/
4444
void forceUpdate();
4545

46+
String getDay();
4647
String getHours();
4748
String getMinutes();
4849
String getSeconds();

keywords.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ NTPClient KEYWORD1
1111
begin KEYWORD2
1212
update KEYWORD2
1313
forceUpdate KEYWORD2
14+
getDay KEYWORD2
1415
getHours KEYWORD2
1516
getMinutes KEYWORD2
1617
getSeconds KEYWORD2
1718
getFormattedTime KEYWORD2
18-
getRawTime KEYWORD2
19+
getRawTime KEYWORD2

0 commit comments

Comments
 (0)