Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created Aug 14, 2021
Embed
What would you like to do?
package main
import "fmt"
func segundosASegundosMinutosYHoras(segundos int) string {
horas := int(segundos / 60 / 60)
segundos -= horas * 60 * 60
minutos := int(segundos / 60)
segundos -= (minutos * 60)
return fmt.Sprintf("%02d:%02d:%02d", horas, minutos, segundos)
}
func main() {
fmt.Println(segundosASegundosMinutosYHoras(10))
fmt.Println(segundosASegundosMinutosYHoras(100))
fmt.Println(segundosASegundosMinutosYHoras(1200))
fmt.Println(segundosASegundosMinutosYHoras(400))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment