MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / seconds2clock

Function seconds2clock

libraries/MathHelpers/MathHelpers.h:140–165  ·  view source on GitHub ↗

(true) 00:00:00 .. 23:59:59 (false) 00:00 .. 23:59

Source from the content-addressed store, hash-verified

138// (true) 00:00:00 .. 23:59:59
139// (false) 00:00 .. 23:59
140char * seconds2clock(uint32_t seconds, bool displaySeconds=false)
141{
142 uint16_t days = seconds / 86400UL; // strips the days
143 seconds -= (days * 86400UL);
144 uint8_t hours = seconds / 3600UL;
145 seconds -= (hours * 3600UL);
146 uint8_t minutes = seconds / 60UL;
147 seconds -= (minutes * 60UL);
148
149 uint8_t pos = 0;
150 __mathHelperBuffer[pos++] = hours/10 + '0';
151 __mathHelperBuffer[pos++] = hours%10 + '0';
152 __mathHelperBuffer[pos++] = ':';
153
154 __mathHelperBuffer[pos++] = minutes/10 + '0';
155 __mathHelperBuffer[pos++] = minutes%10 + '0';
156 if (displaySeconds)
157 {
158 __mathHelperBuffer[pos++] = ':';
159 __mathHelperBuffer[pos++] = seconds/10 + '0';
160 __mathHelperBuffer[pos++] = seconds%10 + '0';
161 }
162 __mathHelperBuffer[pos] = '\0';
163
164 return __mathHelperBuffer;
165}
166
167char * millis2clock(uint32_t millis)
168{

Callers 1

millis2clockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected