Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 14, 2021 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/31304b6966da71be55dcc271d83f55fb to your computer and use it in GitHub Desktop.
Save parzibyte/31304b6966da71be55dcc271d83f55fb to your computer and use it in GitHub Desktop.
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