Projeto bot pontos
This commit is contained in:
24
backend/internal/rules/format.go
Normal file
24
backend/internal/rules/format.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user