1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-16 22:31:03 +02:00

fix(music): hours not being displayed in track duration (#968)

This commit is contained in:
postsolar 2025-05-12 11:16:06 +03:00 committed by GitHub
parent d31ac29db0
commit 4d92af7ced
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,13 +40,18 @@ pub enum PlayerCommand {
}
/// Formats a duration given in seconds
/// in hh:mm format
/// in hh:mm:ss format
fn format_time(duration: Duration) -> String {
let time = duration.as_secs();
let hours = time / (60 * 60);
let minutes = (time / 60) % 60;
let seconds = time % 60;
format!("{minutes:0>2}:{seconds:0>2}")
if hours > 0 {
format!("{hours}:{minutes:0>2}:{seconds:0>2}")
} else {
format!("{minutes:0>2}:{seconds:0>2}")
}
}
/// Extracts the formatting tokens from a formatting string