minor changes
This commit is contained in:
parent
57f774ae8d
commit
601a29023a
1 changed files with 21 additions and 14 deletions
|
@ -32,6 +32,12 @@ Ox.formatDate <f> Formats a date according to a format string
|
|||
<a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/strftime.3.html">strftime</a>
|
||||
and <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>.
|
||||
'%Q' (quarter) and '%X'/'%x' (year with 'BC'/'AD') are non-standard
|
||||
(str) -> <s> formatted date
|
||||
(date, str) -> <s> formatted date
|
||||
(date, str, utc) -> <s> formatted date
|
||||
str <s> format string
|
||||
date <d|n|s> date
|
||||
utc <b> date is utc
|
||||
<script>
|
||||
Ox.test.date = new Date('2005-01-02 00:03:04');
|
||||
</script>
|
||||
|
@ -124,7 +130,6 @@ Ox.formatDate <f> Formats a date according to a format string
|
|||
@*/
|
||||
|
||||
Ox.formatDate = function(date, str, utc) {
|
||||
// fixme: date and utc are optional, date can be date, number or string
|
||||
if (date === '') {
|
||||
return '';
|
||||
}
|
||||
|
@ -394,6 +399,15 @@ Ox.formatDegrees = function(deg, mode) {
|
|||
);
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.formatDimensions <f> Formats valus as dimension
|
||||
> Ox.formatDimensions([1920, 1080], 'px')
|
||||
"1920 x 1080 px"
|
||||
@*/
|
||||
Ox.formatDimensions = Ox.formatResolution = function(arr, str) {
|
||||
return arr.join(' x ') + (str ? ' ' + str : '');
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.formatDuration <f> Formats a duration as a string
|
||||
> Ox.formatDuration(3599.999)
|
||||
|
@ -466,6 +480,9 @@ Ox.formatDuration = function(/*sec, dec, format*/) {
|
|||
|
||||
/*@
|
||||
Ox.formatNumber <f> Formats a number with thousands separators
|
||||
(num, dec) -> <s> format number to string
|
||||
num <n> number
|
||||
dec <n|0> number of decimals
|
||||
> Ox.formatNumber(123456789, 3)
|
||||
"123,456,789.000"
|
||||
> Ox.formatNumber(-2000000 / 3, 3)
|
||||
|
@ -474,7 +491,6 @@ Ox.formatNumber <f> Formats a number with thousands separators
|
|||
"666,667"
|
||||
@*/
|
||||
Ox.formatNumber = function(num, dec) {
|
||||
// fixme: specify decimal and thousands separators
|
||||
var arr = [],
|
||||
abs = Math.abs(num),
|
||||
str = Ox.isUndefined(dec) ? abs.toString() : abs.toFixed(dec),
|
||||
|
@ -530,15 +546,6 @@ Ox.formatPercent = function(num, total, dec) {
|
|||
return Ox.formatNumber(num / total * 100, dec) + '%'
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.formatResolution <f> Formats two values as a resolution
|
||||
> Ox.formatResolution([1920, 1080], 'px')
|
||||
"1920 x 1080 px"
|
||||
@*/
|
||||
// fixme: should be formatDimensions
|
||||
Ox.formatResolution = function(arr, str) {
|
||||
return arr[0] + ' x ' + arr[1] + (str ? ' ' + str : '');
|
||||
}
|
||||
|
||||
/*@
|
||||
Ox.formatString <f> Basic string formatting
|
||||
|
@ -548,8 +555,6 @@ Ox.formatString <f> Basic string formatting
|
|||
'foobar'
|
||||
@*/
|
||||
|
||||
// fixme: Ox.formatRoman() ?
|
||||
|
||||
Ox.formatString = function (str, obj) {
|
||||
return str.replace(/\{([^}]+)\}/g, function(str, match) {
|
||||
return obj[match];
|
||||
|
@ -582,6 +587,8 @@ Ox.formatValue = function(num, str, bin) {
|
|||
|
||||
/*@
|
||||
Ox.formatUnit <f> Formats a number with a unit
|
||||
> Ox.formatUnit(0.333333, '%', 2, 100)
|
||||
"33.33%"
|
||||
@*/
|
||||
Ox.formatUnit = function(num, str, dec, factor) {
|
||||
dec = Ox.isUndefined(dec) ? 3 : dec;
|
||||
|
@ -608,4 +615,4 @@ Ox.parseDuration = function(str) {
|
|||
return split.reduce(function(prev, curr, i) {
|
||||
return prev + (parseFloat(curr) || 0) * Math.pow(60, i);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue