Skip to content

Instantly share code, notes, and snippets.

@johann-lecocq
Created May 12, 2019 18:18
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 johann-lecocq/01e6f986780c83a455ab409d9c7e4aee to your computer and use it in GitHub Desktop.
Save johann-lecocq/01e6f986780c83a455ab409d9c7e4aee to your computer and use it in GitHub Desktop.
transforme uptime to month, days,hours, minutes and seconds
def transforme(secondes):
m = (("mois ", 2592000), ("jours ", 86400), ("h", 3600), ("m", 60))
chaine = ""
for echelle,nombre_seconde in m:
quotient = secondes // nombre_seconde
secondes = secondes % nombre_seconde
if quotient != 0: chaine += f"{quotient}{echelle}"
return f"{chaine}{secondes}s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment