Return to Snippet

Revision: 30799
at August 22, 2010 22:51 by chrisaiv


Initial Code
public static function timeCode(sec:Number):String 
{
	var h:Number = Math.floor(sec/3600);
	h = isNaN(h) ? 0 : h;
	
	var m:Number = Math.floor((sec%3600)/60);
	m = isNaN(m) ? 0 : m;
	
	var s:Number = Math.floor((sec%3600)%60);
	s = isNaN(s) ? 0 : s;
	
	return (h == 0 ? "":(h<10 ? "0"+h.toString()+":" : h.toString()+":"))+(m<10 ? "0"+m.toString() : m.toString())+":"+(s<10 ? "0"+s.toString() : s.toString());
}

Initial URL

                                

Initial Description

                                

Initial Title
AS3: TimeCode Converter

Initial Tags

                                

Initial Language
ActionScript 3