From 060db5c6cbd02e684a0c98c0f045da242b6ab218 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 9 Oct 2021 14:49:13 +0200 Subject: Add lbry, attempt to fix 4chan posting when captcha is no-op --- src/StringUtils.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/StringUtils.cpp') diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 5706499..494e32f 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -219,4 +219,26 @@ namespace QuickMedia { else return std::to_string(seconds) + " second" + (seconds == 1 ? "" : "s") + " ago"; } + + std::string seconds_to_duration(int seconds) { + seconds = std::max(0, seconds); + + int minutes = seconds / 60; + int hours = minutes / 60; + char buffer[32]; + + if(hours >= 1) { + minutes -= (hours * 60); + seconds -= (hours * 60 * 60); + seconds -= (minutes * 60); + snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", hours, minutes, seconds); + } else if(minutes >= 1) { + seconds -= (minutes * 60); + snprintf(buffer, sizeof(buffer), "%02d:%02d", minutes, seconds); + } else { + snprintf(buffer, sizeof(buffer), "00:%02d", seconds); + } + + return buffer; + } } \ No newline at end of file -- cgit v1.2.3