diff --git a/CHANGELOG b/CHANGELOG index 6a082d5..06bd671 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Added function to get dayof month - 2020.10.07 + NTPClient 3.1.0 - 2016.05.31 * Added functions for changing the timeOffset and updateInterval later. Thanks @SirUli diff --git a/NTPClient.cpp b/NTPClient.cpp index 760e142..02bc083 100755 --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -135,6 +135,14 @@ unsigned long NTPClient::getEpochTime() const { int NTPClient::getDay() const { return (((this->getEpochTime() / 86400L) + 4 ) % 7); //0 is Sunday } + +int NTPClient::getDayOfMonth() const { + time_t rawtime = this->getEpochTime() ; + struct tm * ti; + ti = localtime (&rawtime); + return ti->tm_mday; // day of month +} + int NTPClient::getHours() const { return ((this->getEpochTime() % 86400L) / 3600); } @@ -207,4 +215,4 @@ void NTPClient::sendNTPPacket() { void NTPClient::setRandomPort(unsigned int minValue, unsigned int maxValue) { randomSeed(analogRead(0)); this->_port = random(minValue, maxValue); -} \ No newline at end of file +} diff --git a/NTPClient.h b/NTPClient.h index b518c28..5cc6c93 100755 --- a/NTPClient.h +++ b/NTPClient.h @@ -75,6 +75,7 @@ class NTPClient { bool forceUpdate(); int getDay() const; + int getDayOfMonth(); int getHours() const; int getMinutes() const; int getSeconds() const;