Skip to content

Instantly share code, notes, and snippets.

View johann-lecocq's full-sized avatar
🐙

Johann Lecocq johann-lecocq

🐙
View GitHub Profile
@johann-lecocq
johann-lecocq / transforme.py
Created May 12, 2019 18:18
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"