move Ox.parseDuration to String.js
This commit is contained in:
parent
a34c406d78
commit
6e7743efd3
1 changed files with 17 additions and 0 deletions
|
@ -104,6 +104,23 @@ Ox.pad = function(string, length, padding) {
|
||||||
: (string + padding).slice(0, length);
|
: (string + padding).slice(0, length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@
|
||||||
|
Ox.parseDuration <f> Takes a formatted duration, returns seconds
|
||||||
|
> Ox.parseDuration('01:02:03')
|
||||||
|
3723
|
||||||
|
> Ox.parseDuration('3')
|
||||||
|
3
|
||||||
|
> Ox.parseDuration('2:')
|
||||||
|
120
|
||||||
|
> Ox.parseDuration('1::')
|
||||||
|
3600
|
||||||
|
@*/
|
||||||
|
Ox.parseDuration = function(string) {
|
||||||
|
return string.split(':').reverse().slice(0, 3).reduce(function(p, c, i) {
|
||||||
|
return p + (parseFloat(c) || 0) * Math.pow(60, i);
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.parsePath <f> Returns the components of a path
|
Ox.parsePath <f> Returns the components of a path
|
||||||
(str) -> <o> Path
|
(str) -> <o> Path
|
||||||
|
|
Loading…
Reference in a new issue