25 lines
604 B
Go
25 lines
604 B
Go
package rules
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// FormatMinutes formata uma duração de jornada: 480 → "8h00", 390 → "6h30".
|
|
func FormatMinutes(minutes int) string {
|
|
return fmt.Sprintf("%dh%02d", minutes/60, minutes%60)
|
|
}
|
|
|
|
// FormatMinutesShort formata intervalos curtos: 15 → "15 min", 60 → "1h00".
|
|
func FormatMinutesShort(minutes int) string {
|
|
if minutes < 60 {
|
|
return fmt.Sprintf("%d min", minutes)
|
|
}
|
|
return FormatMinutes(minutes)
|
|
}
|
|
|
|
// FormatClock formata o horário no fuso informado: "13:02".
|
|
func FormatClock(t time.Time, loc *time.Location) string {
|
|
return t.In(loc).Format("15:04")
|
|
}
|