var Util = { zeroize: function(value, length) { value = new String(value); if (value.length >= length) { return value; } return Util.zeroize('0' + value, length); }, date: { format: function(timestamp) { if (typeof(timestamp) != 'number') { timestamp = parseInt(timestamp, 10); } var date = new Date(timestamp); return new String(date.getFullYear()) + '-' + Util.zeroize(date.getMonth() + 1, 2) + '-' + Util.zeroize(date.getDate(), 2); }, formatFromYmd: function(date) { var dateArray = date.split('-'); return new String(dateArray[0]) + '-' + Util.zeroize(dateArray[1], 2) + '-' + Util.zeroize(dateArray[2], 2); }, formatToFull: function(timestamp) { if (typeof(timestamp) != 'number') { timestamp = parseInt(timestamp, 10); } var date = new Date(timestamp); return new String(date.getFullYear()) + '年' + new String(date.getMonth() + 1) + '月' + new String(date.getDate()) + '日'; }, formatToShort: function(timestamp) { if (typeof(timestamp) != 'number') { timestamp = parseInt(timestamp, 10); } var date = new Date(timestamp); return new String(date.getMonth() + 1) + '月' + new String(date.getDate()) + '日'; }, floor: function(timestamp) { if (arguments[0] === undefined) { timestamp = Util.date.now(); } return Date.parse(Util.date.format(timestamp)); }, parse: function(date) { return Date.parse(date); }, now: function() { return (new Date()).getTime(); }, formatTime: function(timestamp) { var date = arguments[0] === undefined ? new Date : new Date(timestamp); return Util.zeroize(date.getHours(), 2) + ':' + Util.zeroize(date.getMinutes(), 2); } }, updateIcon: function(path) { //chrome.browserAction.setIcon({'path': path}); //document.getElementById('hasData').setAttribute('src', path); }, popup: function() { chrome.browserAction.executeAction({'extensionId': config.appId}); } };