From 885ce9e9e928db08e85e7bd2e249f8142062ccd2 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 17 Oct 2012 01:33:26 +0200 Subject: [PATCH] Cleans code. --- src/_h5ai/client/js/inc/core/format.js | 38 +------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/_h5ai/client/js/inc/core/format.js b/src/_h5ai/client/js/inc/core/format.js index edebc71d..d2267d5c 100644 --- a/src/_h5ai/client/js/inc/core/format.js +++ b/src/_h5ai/client/js/inc/core/format.js @@ -1,8 +1,7 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { - var reParseSize = /^\s*([\.\d]+)\s*([kmgt]?)b?\s*$/i, - decimalMetric = { + var decimalMetric = { t: 1000.0, k: 1000.0, u: ['B', 'KB', 'MB', 'GB', 'TB'] @@ -15,30 +14,6 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { defaultMetric = decimalMetric, defaultDateFormat = 'YYYY-MM-DD HH:mm', - parseSize = function (str) { - - var match = reParseSize.exec(str), - kilo = decimalMetric.k, - val, unit; - - if (!match) { - return null; - } - - val = parseFloat(match[1]); - unit = match[2].toLowerCase(); - if (unit === 'k') { - val *= kilo; - } else if (unit === 'm') { - val *= kilo * kilo; - } else if (unit === 'g') { - val *= kilo * kilo * kilo; - } else if (unit === 't') { - val *= kilo * kilo * kilo * kilo; - } - return val; - }, - setDefaultMetric = function (metric) { if (!metric) { @@ -73,15 +48,6 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { defaultDateFormat = dateFormat; }, - parseDate = function (str, dateFormat) { - - try { // problems with ie < 9 :( - return moment(str, dateFormat || defaultDateFormat).valueOf() || null; - } catch (err) {} - - return Date.parse(str).valueOf() || null; - }, - formatDate = function (millis, dateFormat) { if (!_.isNumber(millis) || !millis) { @@ -92,11 +58,9 @@ modulejs.define('core/format', ['_', 'moment'], function (_, moment) { }; return { - parseSize: parseSize, setDefaultMetric: setDefaultMetric, formatSize: formatSize, setDefaultDateFormat: setDefaultDateFormat, - parseDate: parseDate, formatDate: formatDate }; });