diff --git a/source/Ox/js/Format.js b/source/Ox/js/Format.js index fb18dfa8..175e1d68 100644 --- a/source/Ox/js/Format.js +++ b/source/Ox/js/Format.js @@ -32,6 +32,12 @@ Ox.formatDate Formats a date according to a format string strftime and ISO 8601. '%Q' (quarter) and '%X'/'%x' (year with 'BC'/'AD') are non-standard + (str) -> formatted date + (date, str) -> formatted date + (date, str, utc) -> formatted date + str format string + date date + utc date is utc @@ -124,7 +130,6 @@ Ox.formatDate 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 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 Formats a duration as a string > Ox.formatDuration(3599.999) @@ -466,6 +480,9 @@ Ox.formatDuration = function(/*sec, dec, format*/) { /*@ Ox.formatNumber Formats a number with thousands separators + (num, dec) -> format number to string + num number + dec number of decimals > Ox.formatNumber(123456789, 3) "123,456,789.000" > Ox.formatNumber(-2000000 / 3, 3) @@ -474,7 +491,6 @@ Ox.formatNumber 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 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 Basic string formatting @@ -548,8 +555,6 @@ Ox.formatString 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 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); -} \ No newline at end of file +}