Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active August 18, 2021 23:03
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/3a5924edd6d9b804e669071ef15ae7ca to your computer and use it in GitHub Desktop.
Save parzibyte/3a5924edd6d9b804e669071ef15ae7ca to your computer and use it in GitHub Desktop.
# https://parzibyte.me/blog
from datetime import datetime, timedelta
def obtener_tiempo_transcurrido(segundos):
dias = int(segundos / 60 / 60 / 24)
segundos -= dias * 60 * 60 * 24
horas = int(segundos / 60 / 60)
segundos -= horas*60*60
minutos = int(segundos/60)
segundos -= minutos*60
return f"{dias} días, {horas} horas, {minutos} minutos y {segundos} segundos"
ahora = datetime.now()
futuro = ahora + timedelta(hours=50, seconds=925)
diferencia = futuro-ahora
legible = obtener_tiempo_transcurrido(diferencia.total_seconds())
print(legible)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment