Hi there,
in a discussion on discord there was the question raised to convert seconds into a SMPTE string, so i came up with an addition for RelativeTime:
String RelativeTime::toString (bool includeDays) const
{
String result;
result.preallocateBytes (32);
if (numSeconds < 0)
result << '-';
bool empty = true;
if (includeDays) {
auto days = (int)inDays();
if (days > 0) {
result << String (days) << ' ';
empty = false;
}
}
result << String ((int)inHours() % 24).paddedLeft ('0', empty ? 1 : 2) << ':';
result << String ((int)inMinutes() % 60).paddedLeft ('0', 2) << ':';
result << String ((int)inSeconds() % 60).paddedLeft ('0', 2);
auto millis = (int)inMilliseconds() % 1000;
if (millis > 0)
result << '.' << String (millis).paddedLeft ('0', 3);
return result.trimEnd();
}
Pretty straight forward. Maybe it’s useful for others as well, so it would be cool if that could be added…
Cheers,
Daniel