Skip to content

Instantly share code, notes, and snippets.

@FlorianBELLAZOUZ
Last active November 17, 2015 11:38
Show Gist options
  • Select an option

  • Save FlorianBELLAZOUZ/0c9c9f231c5f38ce6596 to your computer and use it in GitHub Desktop.

Select an option

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"
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