(secs: f64, with_suffix: bool)
| 107 | |
| 108 | #[tracing::instrument(level = "debug", skip(secs))] |
| 109 | pub 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))] |
| 131 | pub fn convert_file_src(path: String) -> String { |
no outgoing calls
no test coverage detected