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

Function seconds2clock12

libraries/dateTimeHelpers/dateTimeHelpers.h:113–141  ·  view source on GitHub ↗

for completeness shows no AM/PM or 13-23.

Source from the content-addressed store, hash-verified

111
112// for completeness shows no AM/PM or 13-23.
113char * seconds2clock12(uint32_t seconds, bool displaySeconds = false)
114{
115 char * buf = __dateTimeHelperBuffer;
116 uint8_t pos = 0;
117
118 uint16_t days;
119 uint8_t hours, minutes, sec;
120 secondsSplit(seconds, &days, &hours, &minutes, &sec);
121
122 if (hours > 12) hours -= 12;
123 uint8_t t = hours / 10;
124 buf[pos++] = t + '0';
125 buf[pos++] = hours - (t * 10) + '0';
126 buf[pos++] = ':';
127
128 t = minutes / 10;
129 buf[pos++] = t + '0';
130 buf[pos++] = minutes - (t * 10) + '0';
131 if (displaySeconds)
132 {
133 buf[pos++] = ':';
134 t = sec / 10;
135 buf[pos++] = t + '0';
136 buf[pos++] = sec - (t * 10) + '0';
137 }
138 buf[pos] = '\0';
139
140 return buf;
141}
142
143
144// (true) 00:00:00 .. 12:59:59 AM/PM

Callers

nothing calls this directly

Calls 1

secondsSplitFunction · 0.85

Tested by

no test coverage detected