forked from 0x2620/oxjs
misc updates; add geo demo
This commit is contained in:
parent
09a3537dc1
commit
34753cb2ed
9 changed files with 219 additions and 81 deletions
|
|
@ -274,7 +274,8 @@ Ox.formatDateRange = function(start, end, utc) {
|
|||
Ox.formatDate(dates[0], formats[precision[0] - 1], utc),
|
||||
Ox.formatDate(dates[1], formats[precision[1] - 1], utc)
|
||||
];
|
||||
// if same year, and neither date is more precise than day, then omit first year
|
||||
// if same year, and neither date is more precise than day,
|
||||
// then omit first year
|
||||
if (
|
||||
parts[0][0] == parts[1][0]
|
||||
&& precision[0] <= 3
|
||||
|
|
@ -553,3 +554,24 @@ Ox.formatUnit = function(num, str, dec, factor) {
|
|||
factor = Ox.isUndefined(factor) ? 1 : factor;
|
||||
return Ox.formatNumber(num * factor, dec) + (str == '%' ? '' : ' ') + str;
|
||||
};
|
||||
|
||||
/*@
|
||||
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(str) {
|
||||
var split = str.split(':').reverse();
|
||||
while (split.length > 3) {
|
||||
split.pop();
|
||||
}
|
||||
return split.reduce(function(prev, curr, i) {
|
||||
return prev + (parseFloat(curr) || 0) * Math.pow(60, i);
|
||||
}, 0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue