Handle hours >= 100

2.0.x
Scott Lahteine 8 years ago
parent 9f706a9635
commit c6859a1e54

@ -146,12 +146,14 @@ struct duration_t {
* 11d 12:33 * 11d 12:33
*/ */
void toDigital(char *buffer, bool with_days=false) const { void toDigital(char *buffer, bool with_days=false) const {
uint16_t h = uint16_t(this->hour() % 24UL), uint16_t h = uint16_t(this->hour()),
m = uint16_t(this->minute() % 60UL); m = uint16_t(this->minute() % 60UL);
if (with_days) if (with_days)
sprintf_P(buffer, PSTR("%ud %02u:%02u"), this->day(), h, m); sprintf_P(buffer, PSTR("%ud %02u:%02u"), this->day(), h, m);
else if (h < 100)
sprintf_P(buffer, PSTR("%02u:%02u"), h % 24, m);
else else
sprintf_P(buffer, PSTR("%02u:%02u"), h, m); sprintf_P(buffer, PSTR("%u:%02u"), h, m);
} }
}; };

Loading…
Cancel
Save