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

Function seconds2clock24

libraries/dateTimeHelpers/dateTimeHelpers.h:82–109  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

80// (true) 00:00:00 .. 23:59:59
81// (false) 00:00 .. 23:59
82char * seconds2clock24(uint32_t seconds, bool displaySeconds = false)
83{
84 char * buf = __dateTimeHelperBuffer;
85 uint8_t pos = 0;
86
87 uint16_t days;
88 uint8_t hours, minutes, sec;
89 secondsSplit(seconds, &days, &hours, &minutes, &sec);
90
91 uint8_t t = hours / 10;
92 buf[pos++] = t + '0';
93 buf[pos++] = hours - (t * 10) + '0';
94 buf[pos++] = ':';
95
96 t = minutes / 10;
97 buf[pos++] = t + '0';
98 buf[pos++] = minutes - (t * 10) + '0';
99 if (displaySeconds)
100 {
101 buf[pos++] = ':';
102 t = sec / 10;
103 buf[pos++] = t + '0';
104 buf[pos++] = sec - (t * 10) + '0';
105 }
106 buf[pos] = '\0';
107
108 return buf;
109}
110
111
112// for completeness shows no AM/PM or 13-23.

Callers 1

millis2clockFunction · 0.85

Calls 1

secondsSplitFunction · 0.85

Tested by

no test coverage detected