Last active
November 17, 2015 11:38
-
-
Save FlorianBELLAZOUZ/0c9c9f231c5f38ce6596 to your computer and use it in GitHub Desktop.
Convertir secondes en chaines de cratère, exemple : convetiseurSeconde(50403) == "1j 11h 0m 3s"
This file contains hidden or 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
| function convertiseurSeconde(secondes){ | |
| var d = [["s",60],["m",60],["h",24],["j",30],["m",12],["a",100],["s",10],["m",Infinity]]; | |
| var cur = 0, out = ""; | |
| return ((function (last){ | |
| out = Math.floor(last)%d[cur][1]+d[cur][0]+" "+out; | |
| if(last >= d[cur][1]) arguments.callee((cur++,last / d[cur][1])); | |
| })(secondes),out); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment