package main import ( "barista.run/pango" "fmt" "time" ) var spacer = pango.Text(" ").XXSmall() func truncate(in string, l int) string { if len([]rune(in)) <= l { return in } return string([]rune(in)[:l-1]) + "⋯" } func hms(d time.Duration) (h int, m int, s int) { h = int(d.Hours()) m = int(d.Minutes()) % 60 s = int(d.Seconds()) % 60 return } func formatMediaTime(d time.Duration) string { h, m, s := hms(d) if h > 0 { return fmt.Sprintf("%d:%02d:%02d", h, m, s) } return fmt.Sprintf("%d:%02d", m, s) }