@@ -133,27 +133,42 @@ unsigned long NTPClient::getEpochTime() const {
133
133
}
134
134
135
135
int 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
137
140
}
138
141
int 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 );
140
146
}
141
147
int 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 );
143
152
}
144
153
int 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 );
146
158
}
147
159
148
160
String 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);
151
166
String hoursStr = hours < 10 ? " 0" + String (hours) : String (hours);
152
167
153
- unsigned long minutes = (rawTime % 3600 ) / 60 ;
168
+ unsigned long minutes = getMinutes (rawTime) ;
154
169
String minuteStr = minutes < 10 ? " 0" + String (minutes) : String (minutes);
155
170
156
- unsigned long seconds = rawTime % 60 ;
171
+ unsigned long seconds = getSeconds ( rawTime) ;
157
172
String secondStr = seconds < 10 ? " 0" + String (seconds) : String (seconds);
158
173
159
174
return hoursStr + " :" + minuteStr + " :" + secondStr;
0 commit comments