Bug 1434844 - Download timeLeft is now formatted according to locale; r=gandalf
☠☠ backed out by d29a10db52dc ☠ ☠
authorPeter Dodds <peter.sa.d@hotmail.com>
Sun, 04 Mar 2018 22:56:31 -0500
changeset 409585 c91f7e66f342
parent 409584 fc6d9baa6cc9
child 409586 75aaafadfe9d
push id61575
push userryanvm@gmail.com
push dateThu, 22 Mar 2018 23:48:12 +0000
treeherderautoland@c91f7e66f342 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgandalf
bugs1434844
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434844 - Download timeLeft is now formatted according to locale; r=gandalf MozReview-Commit-ID: LZjna3vDSDB
toolkit/mozapps/downloads/DownloadUtils.jsm
--- a/toolkit/mozapps/downloads/DownloadUtils.jsm
+++ b/toolkit/mozapps/downloads/DownloadUtils.jsm
@@ -246,16 +246,17 @@ var DownloadUtils = {
    *
    * @param aSeconds
    *        Current estimate on number of seconds left for the download
    * @param [optional] aLastSec
    *        Last time remaining in seconds or Infinity for unknown
    * @return A pair: [time left text, new value of "last seconds"]
    */
   getTimeLeft: function DU_getTimeLeft(aSeconds, aLastSec) {
+    let nf = new Services.intl.NumberFormat();
     if (aLastSec == null)
       aLastSec = Infinity;
 
     if (aSeconds < 0)
       return [gBundle.GetStringFromName(gStr.timeUnknown), aLastSec];
 
     // Try to find a cached lastSec for the given second
     aLastSec = gCachedLast.reduce((aResult, aItem) =>
@@ -288,19 +289,19 @@ var DownloadUtils = {
       // Be friendly in the last few seconds
       timeLeft = gBundle.GetStringFromName(gStr.timeFewSeconds);
     } else {
       // Convert the seconds into its two largest units to display
       let [time1, unit1, time2, unit2] =
         DownloadUtils.convertTimeUnits(aSeconds);
 
       let pair1 =
-        gBundle.formatStringFromName(gStr.timePair, [time1, unit1], 2);
+        gBundle.formatStringFromName(gStr.timePair, [nf.format(time1), unit1], 2);
       let pair2 =
-        gBundle.formatStringFromName(gStr.timePair, [time2, unit2], 2);
+        gBundle.formatStringFromName(gStr.timePair, [nf.format(time2), unit2], 2);
 
       // Only show minutes for under 1 hour unless there's a few minutes left;
       // or the second pair is 0.
       if ((aSeconds < 3600 && time1 >= 4) || time2 == 0) {
         timeLeft = gBundle.formatStringFromName(gStr.timeLeftSingle,
                                                 [pair1], 1);
       } else {
         // We've got 2 pairs of times to display