1pub fn format_seconds(ms: u64) -> String {
5 let mut seconds = format!("{:.1}", ms as f64 / 1000.0);
6 if seconds.ends_with(".0") {
7 seconds.truncate(seconds.len() - 2);
8 }
9 format!("{seconds}s")
10}
11
12pub fn format_wait_limit(ms: u64) -> String {
14 match ms {
15 60_000 => "1 minute".to_string(),
16 ms if ms > 0 && ms % 60_000 == 0 => format!("{} minutes", ms / 60_000),
17 ms => format_seconds(ms),
18 }
19}
20
21pub fn append_trailing_line(text: &mut String, line: &str) {
22 if !text.is_empty() {
23 text.push_str(if text.ends_with('\n') { "\n" } else { "\n\n" });
24 }
25 text.push_str(line);
26}
27
28#[cfg(unix)]
31pub fn append_db_schema_hint(text: &mut String, hint: &str) {
32 append_trailing_line(text, hint);
33}