MCPcopy Create free account
hub / github.com/Komet/MediaElch / secondsToTimeCode

Function secondsToTimeCode

src/utils/Time.cpp:5–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3namespace mediaelch {
4
5QString secondsToTimeCode(quint32 duration)
6{
7 const auto seconds = static_cast<int>(duration % 60);
8 duration /= 60;
9 const auto minutes = static_cast<int>(duration % 60);
10 duration /= 60;
11 const auto hours = static_cast<int>(duration % 24);
12 const auto days = static_cast<int>(duration / 24);
13
14 if (hours == 0 && days == 0) {
15 return QStringLiteral("%1:%2") //
16 .arg(minutes, 2, 10, QChar('0'))
17 .arg(seconds, 2, 10, QChar('0'));
18 }
19
20 if (days == 0) {
21 return QStringLiteral("%1:%2:%3")
22 .arg(hours, 2, 10, QChar('0'))
23 .arg(minutes, 2, 10, QChar('0'))
24 .arg(seconds, 2, 10, QChar('0'));
25 }
26
27 return QStringLiteral("%1d%2:%3:%4")
28 .arg(days)
29 .arg(hours, 2, 10, QChar('0'))
30 .arg(minutes, 2, 10, QChar('0'))
31 .arg(seconds, 2, 10, QChar('0'));
32}
33
34
35} // namespace mediaelch

Callers 2

testTime.cppFile · 0.85
captureImageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected