about:startup - present correctly localized dates in the tables (localizing the dates in the graph is tricker), Also, fix the calculation for the minimum value of the graph's x axis (forgot to take into account the funkiness of javascript's numbers)
authorDaniel Brooks <db48x@db48x.net>
Fri, 29 Oct 2010 15:10:10 -0500
changeset 58868 5bc82216672f67f86b754a5a10fa0e5667e75b7f
parent 58867 98ba0272986dc4d6229cb5da562905cd606d7d54
child 58869 852178715a8c130afaa6eead2e881080f1e808bf
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
milestone2.0b8pre
about:startup - present correctly localized dates in the tables (localizing the dates in the graph is tricker), Also, fix the calculation for the minimum value of the graph's x axis (forgot to take into account the funkiness of javascript's numbers)
toolkit/content/aboutStartup.js
--- a/toolkit/content/aboutStartup.js
+++ b/toolkit/content/aboutStartup.js
@@ -33,16 +33,18 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 Components.utils.import("resource://gre/modules/Services.jsm");
+let dateService = Cc["@mozilla.org/intl/scriptabledateformat;1"]
+                    .getService(Ci.nsIScriptableDateFormat);
 
 let strings = Services.strings.createBundle("chrome://global/locale/aboutStartup.properties");
 let branding = Services.strings.createBundle("chrome://branding/locale/brand.properties");
 let brandShortName = branding.GetStringFromName("brandShortName");
 
 function displayTimestamp(id, µs) document.getElementById(id).textContent = formatstamp(µs);
 function displayDuration(id, µs) document.getElementById(id).nextSibling.textContent = formatms(msFromµs(µs));
 
@@ -61,19 +63,24 @@ function formatStr(str, args)
   } catch (x) {
     return str +" "+ args.toSource();
   }
 }
 function appVersion(version, build) formatStr("appVersion", [brandShortName, version, build]);
 function formatExtension(str, name, version) formatStr("extension"+(str.replace(/^on/, "")
                                                                        .replace(/ing$/, "ed")),
                                                        [name, version]);
+function formatDate(date) dateService.FormatDateTime("", dateService.dateFormatLong,
+                                                     dateService.timeFormatSeconds,
+                                                     date.getFullYear(), date.getMonth()+1,
+                                                     date.getDate(), date.getHours(),
+                                                     date.getMinutes(), date.getSeconds());
 
 function msFromµs(µs) µs / 1000;
-function formatstamp(µs) new Date(msFromµs(µs));
+function formatstamp(µs) formatDate(new Date(msFromµs(µs)));
 function formatµs(µs) µs + " µs";
 function formatms(ms) formatStr("milliseconds", [ms]);
 
 function point(stamp, µs, v, b) [msFromµs(stamp), msFromµs(µs), { appVersion: v, appBuild: b }];
 function range(a, b) ({ from: msFromµs(a), to: msFromµs(b || a) });
 function mark(x, y) { var r = {}; x && (r.xaxis = x); y && (r.yaxis = y); return r };
 function label(r, l) $.extend(r, { label: l });
 function color(r, c) $.extend(r, { color: c });
@@ -239,19 +246,20 @@ function populateMeasurements()
     handleCompletion: function()
     {
       var table = $("table");
       var height = $(window).height() - (table.offset().top +
                                          table.outerHeight(true))
                                       - 110;
       $("#graph").height(Math.max(350, height));
 
-      options.xaxis.min = clamp(Date.now() - 3600000,    // 1 hour in milliseconds
-                                series[0].data[0][0],
-                                Date.now() - 604800000); // 7 days in milliseconds
+      options.xaxis.min = Date.now() - clamp(3600000,    // 1 hour in milliseconds
+                                             Date.now() - series[0].data[0][0],
+                                             604800000); // 7 days in milliseconds
+
       var max = 0;
       for each (let [stamp, d] in series[0].data)
         if (stamp >= options.xaxis.min && d > max)
           max = d;
       options.yaxis.max = max;
 
       graph = $.plot($("#graph"), series, options);