@@ -133,27 +133,42 @@ unsigned long NTPClient::getEpochTime() const {
133133}
134134
135135int NTPClient::getDay () const {
136- return (((this ->getEpochTime () / 86400L ) + 4 ) % 7 ); // 0 is Sunday
136+ return getDay (this ->getEpochTime ());
137+ }
138+ unsigned long NTPClient::getDay (unsigned long epochTime) const {
139+ return (((epochTime / 86400L ) + 4 ) % 7 ); // 0 is Sunday
137140}
138141int NTPClient::getHours () const {
139- return ((this ->getEpochTime () % 86400L ) / 3600 );
142+ return getHours (this ->getEpochTime ());
143+ }
144+ unsigned long NTPClient::getHours (unsigned long epochTime) const {
145+ return ((epochTime % 86400L ) / 3600 );
140146}
141147int NTPClient::getMinutes () const {
142- return ((this ->getEpochTime () % 3600 ) / 60 );
148+ return getMinutes (this ->getEpochTime ());
149+ }
150+ unsigned long NTPClient::getMinutes (unsigned long epochTime) const {
151+ return ((epochTime % 3600 ) / 60 );
143152}
144153int NTPClient::getSeconds () const {
145- return (this ->getEpochTime () % 60 );
154+ return getSeconds (this ->getEpochTime ());
155+ }
156+ unsigned long NTPClient::getSeconds (unsigned long epochTime) const {
157+ return (epochTime % 60 );
146158}
147159
148160String NTPClient::getFormattedTime () const {
149- unsigned long rawTime = this ->getEpochTime ();
150- unsigned long hours = (rawTime % 86400L ) / 3600 ;
161+ return getFormattedTime (this ->getEpochTime ());
162+ }
163+
164+ String NTPClient::getFormattedTime (unsigned long rawTime) const {
165+ unsigned long hours = getHours (rawTime);
151166 String hoursStr = hours < 10 ? " 0" + String (hours) : String (hours);
152167
153- unsigned long minutes = (rawTime % 3600 ) / 60 ;
168+ unsigned long minutes = getMinutes (rawTime) ;
154169 String minuteStr = minutes < 10 ? " 0" + String (minutes) : String (minutes);
155170
156- unsigned long seconds = rawTime % 60 ;
171+ unsigned long seconds = getSeconds ( rawTime) ;
157172 String secondStr = seconds < 10 ? " 0" + String (seconds) : String (seconds);
158173
159174 return hoursStr + " :" + minuteStr + " :" + secondStr;
0 commit comments