mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,61 @@
|
||||
package org.osmf.utils
|
||||
{
|
||||
[ExcludeClass]
|
||||
public class TimeUtil
|
||||
{
|
||||
|
||||
public function TimeUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function parseTime(value:String) : Number
|
||||
{
|
||||
var mul:int = 0;
|
||||
var time:Number = 0;
|
||||
var a:Array = value.split(":");
|
||||
if(a.length > 1)
|
||||
{
|
||||
time = a[0] * 3600;
|
||||
time += a[1] * 60;
|
||||
time += Number(a[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
mul = 0;
|
||||
switch(value.charAt(value.length - 1))
|
||||
{
|
||||
case "h":
|
||||
mul = 3600;
|
||||
break;
|
||||
case "m":
|
||||
mul = 60;
|
||||
break;
|
||||
case "s":
|
||||
mul = 1;
|
||||
}
|
||||
if(Boolean(mul))
|
||||
{
|
||||
time = Number(value.substr(0,value.length - 1)) * mul;
|
||||
}
|
||||
else
|
||||
{
|
||||
time = Number(value);
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public static function formatAsTimeCode(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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user