馃尫 the cutsie hackatime helper
at main 442 B view raw
1package utils 2 3import ( 4 "fmt" 5) 6 7func PrettyPrintTime(totalSeconds int) string { 8 hours := totalSeconds / 3600 9 minutes := (totalSeconds % 3600) / 60 10 seconds := totalSeconds % 60 11 12 formattedTime := "" 13 if hours > 0 { 14 formattedTime += fmt.Sprintf("%d hours, ", hours) 15 } 16 if minutes > 0 || hours > 0 { 17 formattedTime += fmt.Sprintf("%d minutes, ", minutes) 18 } 19 formattedTime += fmt.Sprintf("%d seconds", seconds) 20 21 return formattedTime 22}