Skip to content

Instantly share code, notes, and snippets.

@Hunter87ff
Created October 27, 2023 14:24
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 Hunter87ff/f44f8900a0aff5ec3163ddc4efb1e351 to your computer and use it in GitHub Desktop.
Save Hunter87ff/f44f8900a0aff5ec3163ddc4efb1e351 to your computer and use it in GitHub Desktop.
time format from delta (0:40:45.3456456)
def time_format(delta): #0:40:45.3456456
delta = str(delta)
time = ""
lst = delt.split(".")[0].split(":")
if(len(lst)<=3):
h,m,s = delt.split(".")[0].split(":")
time = f"{h}hr, {m}min, {s}sec"
elif(len(lst)>3):
d,h,m,s = delt.split(".")[0].split(":")
time = f"{d}day, {h}hr, {m}min, {s}sec"
return time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment