|
@@ -127,11 +127,11 @@ struct duration_t {
|
127
|
127
|
* 59s
|
128
|
128
|
*/
|
129
|
129
|
char* toString(char * const buffer) const {
|
130
|
|
- int y = this->year(),
|
131
|
|
- d = this->day() % 365,
|
132
|
|
- h = this->hour() % 24,
|
133
|
|
- m = this->minute() % 60,
|
134
|
|
- s = this->second() % 60;
|
|
130
|
+ const uint16_t y = this->year(),
|
|
131
|
+ d = this->day() % 365,
|
|
132
|
+ h = this->hour() % 24,
|
|
133
|
+ m = this->minute() % 60,
|
|
134
|
+ s = this->second() % 60;
|
135
|
135
|
|
136
|
136
|
if (y) sprintf_P(buffer, PSTR("%iy %id %ih %im %is"), y, d, h, m, s);
|
137
|
137
|
else if (d) sprintf_P(buffer, PSTR("%id %ih %im %is"), d, h, m, s);
|
|
@@ -149,23 +149,29 @@ struct duration_t {
|
149
|
149
|
*
|
150
|
150
|
* Output examples:
|
151
|
151
|
* 123456789 (strlen)
|
|
152
|
+ * 12'34
|
152
|
153
|
* 99:59
|
153
|
154
|
* 11d 12:33
|
154
|
155
|
*/
|
155
|
156
|
uint8_t toDigital(char *buffer, bool with_days=false) const {
|
156
|
|
- uint16_t h = uint16_t(this->hour()),
|
157
|
|
- m = uint16_t(this->minute() % 60UL);
|
|
157
|
+ const uint16_t h = uint16_t(this->hour()),
|
|
158
|
+ m = uint16_t(this->minute() % 60UL);
|
158
|
159
|
if (with_days) {
|
159
|
|
- uint16_t d = this->day();
|
160
|
|
- sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m);
|
|
160
|
+ const uint16_t d = this->day();
|
|
161
|
+ sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45
|
161
|
162
|
return d >= 10 ? 9 : 8;
|
162
|
163
|
}
|
|
164
|
+ else if (!h) {
|
|
165
|
+ const uint16_t s = uint16_t(this->second() % 60UL);
|
|
166
|
+ sprintf_P(buffer, PSTR("%02hu'%02hu"), m, s); // 12'34
|
|
167
|
+ return 5;
|
|
168
|
+ }
|
163
|
169
|
else if (h < 100) {
|
164
|
|
- sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m);
|
|
170
|
+ sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); // 12:34
|
165
|
171
|
return 5;
|
166
|
172
|
}
|
167
|
173
|
else {
|
168
|
|
- sprintf_P(buffer, PSTR("%hu:%02hu"), h, m);
|
|
174
|
+ sprintf_P(buffer, PSTR("%hu:%02hu"), h, m); // 123:45
|
169
|
175
|
return 6;
|
170
|
176
|
}
|
171
|
177
|
}
|