B2G/gecko/browser/components/downloads/src/DownloadsCommon.jsm
/**
   * Generates a very short string representing the given time left.
   *
   * @param aSeconds
   *        Value to be formatted.  It represents the number of seconds, it must
   *        be positive but does not need to be an integer.
   *
   * @return Formatted string, for example "30s" or "2h".  The returned value is
   *         maximum three characters long, at least in English.
   */
Generates a very short string representing the given time left.
@param aSeconds
Value to be formatted.  It represents the number of seconds, it must
be positive but does not need to be an integer.

@return Formatted string, for example "30s" or "2h".  The returned value is
maximum three characters long, at least in English.
Generates a very short string representing the given time left . @param aSeconds Value to be formatted . It represents the number of seconds it must be positive but does not need to be an integer . @return Formatted string for example " 30s " or " 2h " . The returned value is maximum three characters long at least in English .
function DC_formatTimeLeft(aSeconds)
  {
    let seconds = Math.round(aSeconds);
    if (!seconds) {
      return "";
    } else if (seconds <= 30) {
      return DownloadsCommon.strings["shortTimeLeftSeconds"](seconds);
    }
    let minutes = Math.round(aSeconds / 60);
    if (minutes < 60) {
      return DownloadsCommon.strings["shortTimeLeftMinutes"](minutes);
    }
    let hours = Math.round(minutes / 60);
    if (hours < 48) { 
      return DownloadsCommon.strings["shortTimeLeftHours"](hours);
    }
    let days = Math.round(hours / 24);
    return DownloadsCommon.strings["shortTimeLeftDays"](Math.min(days, 99));
  }
function DC_formatTimeLeft ( aSeconds ) { let seconds = Math . round ( aSeconds ) ; if ( ! seconds ) { return "" ; } else if ( seconds <= 30 ) { return DownloadsCommon . strings [ "shortTimeLeftSeconds" ] ( seconds ) ; } let minutes = Math . round ( aSeconds / 60 ) ; if ( minutes < 60 ) { return DownloadsCommon . strings [ "shortTimeLeftMinutes" ] ( minutes ) ; } let hours = Math . round ( minutes / 60 ) ; if ( hours < 48 ) { return DownloadsCommon . strings [ "shortTimeLeftHours" ] ( hours ) ; } let days = Math . round ( hours / 24 ) ; return DownloadsCommon . strings [ "shortTimeLeftDays" ] ( Math . min ( days , 99 ) ) ; }
Generates a very short string representing the given time left.
Generates a very short string representing the given time left .
// Decide what text to show for the time // two days