diff options
Diffstat (limited to 'chrome/browser')
7 files changed, 51 insertions, 12 deletions
diff --git a/chrome/browser/resources/net_internals/details_view.js b/chrome/browser/resources/net_internals/details_view.js index d5d35a4e..8b5d716 100644 --- a/chrome/browser/resources/net_internals/details_view.js +++ b/chrome/browser/resources/net_internals/details_view.js @@ -71,7 +71,8 @@ var DetailsView = (function() { var logEntries = sourceEntry.getLogEntries(); var startDate = timeutil.convertTimeTicksToDate(logEntries[0].time); - addNodeWithText(p, 'div', 'Start Time: ' + startDate.toLocaleString()); + var startTimeDiv = addNodeWithText(p, 'div', 'Start Time: '); + timeutil.addNodeWithDate(startTimeDiv, startDate); sourceEntry.printAsText(div); diff --git a/chrome/browser/resources/net_internals/dns_view.js b/chrome/browser/resources/net_internals/dns_view.js index e7e10af..90867b3 100644 --- a/chrome/browser/resources/net_internals/dns_view.js +++ b/chrome/browser/resources/net_internals/dns_view.js @@ -137,7 +137,7 @@ var DnsView = (function() { var expiresDate = timeutil.convertTimeTicksToDate(e.expiration); var expiresCell = addNode(tr, 'td'); - addTextNode(expiresCell, expiresDate.toLocaleString()); + timeutil.addNodeWithDate(expiresCell, expiresDate); if (logDate > timeutil.convertTimeTicksToDate(e.expiration)) { ++expiredEntries; var expiredSpan = addNode(expiresCell, 'span'); diff --git a/chrome/browser/resources/net_internals/import_view.js b/chrome/browser/resources/net_internals/import_view.js index 41eb694..0cbc09e 100644 --- a/chrome/browser/resources/net_internals/import_view.js +++ b/chrome/browser/resources/net_internals/import_view.js @@ -197,17 +197,16 @@ var ImportView = (function() { if (typeof(ClientInfo) != 'object') return; - var dateString = ''; // Dumps made with the command line option don't have a date, and older // versions of Chrome use a formatted string. // TODO(mmenke): At some point, after Chrome 17 hits stable, remove the // ClientInfo.date case. if (ClientInfo.numericDate) { - dateString = (new Date(ClientInfo.numericDate)).toLocaleString(); + timeutil.addNodeWithDate(this.loadedInfoExportDate_, + new Date(ClientInfo.numericDate)); } else if (ClientInfo.date) { - dateString = ClientInfo.date; + this.loadedInfoExportDate_.innerText = ClientInfo.date; } - this.loadedInfoExportDate_.innerText = dateString; var buildName = ClientInfo.name + diff --git a/chrome/browser/resources/net_internals/prerender_view.js b/chrome/browser/resources/net_internals/prerender_view.js index be64c43..69d5eec 100644 --- a/chrome/browser/resources/net_internals/prerender_view.js +++ b/chrome/browser/resources/net_internals/prerender_view.js @@ -108,7 +108,8 @@ var PrerenderView = (function() { tablePrinter.addCell(historyEntry.final_status); var date = new Date(parseInt(historyEntry.end_time)); - tablePrinter.addCell(date.toLocaleString()); + // TODO(eroman): Switch to addNodeWithDate() + tablePrinter.addCell(timeutil.dateToString(date)); } return tablePrinter; } diff --git a/chrome/browser/resources/net_internals/proxy_view.js b/chrome/browser/resources/net_internals/proxy_view.js index a97d36b..47b37cd 100644 --- a/chrome/browser/resources/net_internals/proxy_view.js +++ b/chrome/browser/resources/net_internals/proxy_view.js @@ -94,7 +94,7 @@ var ProxyView = (function() { var badUntilCell = addNode(tr, 'td'); addTextNode(nameCell, entry.proxy_uri); - addTextNode(badUntilCell, badUntilDate.toLocaleString()); + timeutil.addNodeWithDate(badUntilCell, badUntilDate) } return true; } diff --git a/chrome/browser/resources/net_internals/test_view.js b/chrome/browser/resources/net_internals/test_view.js index e3866d2..e8d2645 100644 --- a/chrome/browser/resources/net_internals/test_view.js +++ b/chrome/browser/resources/net_internals/test_view.js @@ -65,8 +65,8 @@ var TestView = (function() { this.summaryDiv_.innerHTML = ''; var p = addNode(this.summaryDiv_, 'p'); - addTextNode(p, 'Started connection test suite suite on ' + - (new Date()).toLocaleString()); + addTextNode(p, 'Started connection test suite suite on '); + timeutil.addNodeWithDate(p, new Date()); // Add a table that will hold the individual test results. var table = addNode(this.summaryDiv_, 'table'); diff --git a/chrome/browser/resources/net_internals/time_util.js b/chrome/browser/resources/net_internals/time_util.js index c8227b5..0a5532c 100644 --- a/chrome/browser/resources/net_internals/time_util.js +++ b/chrome/browser/resources/net_internals/time_util.js @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -41,9 +41,47 @@ var timeutil = (function() { return (new Date()).getTime(); } + /** + * Adds an HTML representation of |date| to |parentNode|. + * + * @param {DomNode} parentNode + * @param {Date} date + * @returns {DomNode} The node containing the date/time. + */ + function addNodeWithDate(parentNode, date) { + var span = addNodeWithText(parentNode, 'span', dateToString(date)); + span.title = 't=' + date.getTime(); + return span; + } + + /** + * Returns a string representation of |date|. + * + * @param {Date} date + * @returns {String} + */ + function dateToString(date) { + var dateStr = + date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate(); + + // 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 = + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds() + + '.' + paddedMilliseconds; + + return '[' + dateStr + '] ' + timeStr; + } + return { setTimeTickOffset: setTimeTickOffset, convertTimeTicksToDate: convertTimeTicksToDate, - getCurrentTime: getCurrentTime + getCurrentTime: getCurrentTime, + addNodeWithDate: addNodeWithDate, + dateToString: dateToString }; })(); |