From 846351ce494e2c57a8049a633d93f4b4d4be3385 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 30 Mar 2016 22:26:04 -0700 Subject: [PATCH] Adding support for getting numerical day of the week where 0 = Sunday --- NTPClient.cpp | 4 +++- NTPClient.h | 1 + keywords.txt | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NTPClient.cpp b/NTPClient.cpp index 075ac08..f58fbda 100644 --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -89,13 +89,15 @@ unsigned long NTPClient::getRawTime() { ((millis() - this->_lastUpdate) / 1000); // Time since last update } +String NTPClient::getDay() { + return String(((this->getRawTime() / 86400L) + 4 ) % 7); //0 is Sunday +} String NTPClient::getHours() { return String((this->getRawTime() % 86400L) / 3600); } String NTPClient::getMinutes() { return String((this->getRawTime() % 3600) / 60); } - String NTPClient::getSeconds() { return String(this->getRawTime() % 60); } diff --git a/NTPClient.h b/NTPClient.h index 65c8265..9c92d42 100644 --- a/NTPClient.h +++ b/NTPClient.h @@ -43,6 +43,7 @@ class NTPClient { */ void forceUpdate(); + String getDay(); String getHours(); String getMinutes(); String getSeconds(); diff --git a/keywords.txt b/keywords.txt index a76fe7b..d64a538 100644 --- a/keywords.txt +++ b/keywords.txt @@ -11,8 +11,9 @@ NTPClient KEYWORD1 begin KEYWORD2 update KEYWORD2 forceUpdate KEYWORD2 +getDay KEYWORD2 getHours KEYWORD2 getMinutes KEYWORD2 getSeconds KEYWORD2 getFormattedTime KEYWORD2 -getRawTime KEYWORD2 \ No newline at end of file +getRawTime KEYWORD2