MCPcopy Create free account
hub / github.com/Moosync/Moosync / format_duration

Function format_duration

src/utils/common.rs:109–128  ·  view source on GitHub ↗
(secs: f64, with_suffix: bool)

Source from the content-addressed store, hash-verified

107
108#[tracing::instrument(level = "debug", skip(secs))]
109pub fn format_duration(secs: f64, with_suffix: bool) -> String {
110 if secs < 0.0 {
111 return "Live".into();
112 }
113
114 let duration = Duration::seconds(secs as i64);
115 let formatted_time = NaiveTime::from_hms_opt(0, 0, 0).unwrap() + duration;
116
117 let (time, suffix) = if formatted_time.hour() == 0 {
118 (formatted_time.format("%M:%S").to_string(), "Mins")
119 } else {
120 (formatted_time.format("%H:%M:%S").to_string(), "Hours")
121 };
122
123 if with_suffix {
124 format!("{} {}", time, suffix)
125 } else {
126 time
127 }
128}
129
130#[tracing::instrument(level = "debug", skip(path))]
131pub fn convert_file_src(path: String) -> String {

Callers 3

MusicInfoMobileFunction · 0.85
SongDetailsFunction · 0.85
ControlsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected