Created
May 12, 2019 18:18
-
-
Save johann-lecocq/01e6f986780c83a455ab409d9c7e4aee to your computer and use it in GitHub Desktop.
transforme uptime to month, days,hours, minutes and seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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