Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
36 строки
774 B
Go
36 строки
774 B
Go
// Package util provides functionality.
|
|
package util
|
|
|
|
import (
|
|
"log"
|
|
"strconv"
|
|
|
|
"rocketgit.ru/rsmon/worker/config/translator"
|
|
)
|
|
|
|
// FormatDuration provides functionality.
|
|
func FormatDuration(duration int64) string {
|
|
// spew.Dump(translator.Translator)
|
|
hours := duration / 3600
|
|
minutes := (duration - hours*3600) / 60
|
|
// seconds := duration % 60
|
|
str := ""
|
|
if hours > 0 {
|
|
tr, err := translator.Translator.C("hours", float64(hours), 0, strconv.FormatInt(hours, 10))
|
|
if err != nil {
|
|
log.Println("translator error", err)
|
|
return ""
|
|
}
|
|
str = str + tr + ", "
|
|
}
|
|
|
|
tr, err := translator.Translator.C("minutes", float64(minutes), 0, strconv.FormatInt(minutes, 10))
|
|
if err != nil {
|
|
log.Println("translator error", err)
|
|
return ""
|
|
}
|
|
|
|
str += tr
|
|
return str
|
|
}
|