Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Formate un nombre de secondes en dur?e lisible
- function timeStr(sec)
- local d = math.floor(sec/86400) --24*60*60 sec
- local h = math.floor(sec/3600)%24 -- 60x60 sec
- local m = math.floor(sec/60)%60 -- 60sec
- local s = math.floor(sec%60) --Reste
- local str = ""
- if d>0 then str = d>1 and d.." days " or "1 day " end
- if h>0 then str = str..h.."h" end
- if m>0 then str = str..(m>9 and m or "0"..m) end
- if h==0 then str = m>0 and str..":"..(s>9 and s or "0"..s) or s.."s" end
- return str
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement