You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
530 B
32 lines
530 B
3 years ago
|
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)
|
||
|
}
|