feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
35
internal/util/format_duration.go
Обычный файл
35
internal/util/format_duration.go
Обычный файл
@@ -0,0 +1,35 @@
|
||||
// Package util provides functionality.
|
||||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/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
|
||||
}
|
||||
Ссылка в новой задаче
Block a user