move Ox.parseDuration to String.js

This commit is contained in:
rolux 2012-05-27 16:53:23 +02:00
parent 6a2ac97bec
commit b4bb926c0c

View file

@ -681,20 +681,3 @@ Ox.formatValue = function(number, string, bin) {
});
return ret;
};
/*@
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);
};