🚧 Add utils.HourMinSecToSeconds func

This commit is contained in:
Dan Jones 2023-09-07 11:00:16 -05:00
commit a706d16c5a
2 changed files with 44 additions and 0 deletions

View file

@ -3,6 +3,8 @@ package utils
import (
"fmt"
p "path"
"strings"
t "time"
)
func GetShortPath(path string) string {
@ -11,3 +13,15 @@ func GetShortPath(path string) string {
dir = p.Base(dir)
return fmt.Sprintf("%s/%s", dir, base)
}
func HourMinSecToSeconds(time string) float64 {
parts := strings.Split(time, ":")
units := []string{"h", "m", "s"}
units = units[len(units)-len(parts):]
f := ""
for idx, part := range parts {
f = f + part + units[idx]
}
dur, _ := t.ParseDuration(f)
return dur.Seconds()
}