diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 05:51:42 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-29 05:51:42 +0000 |
commit | 6e6ea6dd883cc2012f030a9de901f5083a533fbf (patch) | |
tree | fc7b136f5acf94f6ad56be57a55e86788c5085a0 /chrome/browser/resources/net_internals/time_util.js | |
parent | 7239903ac503741d58e91b19738df29c542509a0 (diff) | |
download | chromium_src-6e6ea6dd883cc2012f030a9de901f5083a533fbf.zip chromium_src-6e6ea6dd883cc2012f030a9de901f5083a533fbf.tar.gz chromium_src-6e6ea6dd883cc2012f030a9de901f5083a533fbf.tar.bz2 |
Tweak date format used on net-internals.
Adds zero-padding for minutes/hours/days, removes the brackets, and uses '-' rather than '/' as date separator.
Review URL: https://chromiumcodereview.appspot.com/9518014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/net_internals/time_util.js')
-rw-r--r-- | chrome/browser/resources/net_internals/time_util.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/chrome/browser/resources/net_internals/time_util.js b/chrome/browser/resources/net_internals/time_util.js index 0a5532c..21c5409 100644 --- a/chrome/browser/resources/net_internals/time_util.js +++ b/chrome/browser/resources/net_internals/time_util.js @@ -61,20 +61,26 @@ var timeutil = (function() { * @returns {String} */ function dateToString(date) { - var dateStr = - date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate(); + var dateStr = date.getFullYear() + '-' + + zeroPad_(date.getMonth() + 1, 2) + '-' + + zeroPad_(date.getDate(), 2); - // Prefix the milliseconds with enough zeros to make it three characters - // long. - var paddedMilliseconds = '' + date.getMilliseconds(); - while (paddedMilliseconds.length < 3) - paddedMilliseconds = '0' + paddedMilliseconds; + var timeStr = zeroPad_(date.getHours(), 2) + ':' + + zeroPad_(date.getMinutes(), 2) + ':' + + zeroPad_(date.getSeconds(), 2) + '.' + + zeroPad_(date.getMilliseconds(), 3); - var timeStr = - date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds() + - '.' + paddedMilliseconds; + return dateStr + ' ' + timeStr; + } - return '[' + dateStr + '] ' + timeStr; + /** + * Prefixes enough zeros to |num| so that it has length |len|. + */ + function zeroPad_(num, len) { + var str = num + ''; + while (str.length < len) + str = '0' + str; + return str; } return { |