function lastActiveToString(secondsAgo) {
    // These constants aren't perfect, but close enough.
    const SECONDS_PER_MINUTE = 60;
    const MINUTES_PER_HOUR = 60;
    const SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
    const HOURS_PER_DAY = 24;
    const SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
    const DAYS_PER_WEEK = 7;
    const SECONDS_PER_WEEK = SECONDS_PER_DAY * DAYS_PER_WEEK;
    const SECONDS_PER_MONTH = SECONDS_PER_DAY * 30.5;
    const SECONDS_PER_YEAR = SECONDS_PER_DAY * 365;

    // Seconds ago.
    if (secondsAgo < SECONDS_PER_MINUTE)
      return 'just now';

    // Minutes ago.
    let minutesAgo = Math.floor(secondsAgo / SECONDS_PER_MINUTE);
    if (minutesAgo < MINUTES_PER_HOUR) {
      return minutesAgo.toString() + maybeMakePlural(' minute', minutesAgo) +
          ' ago';
    }

    // Hours and minutes and ago.
    let hoursAgo = Math.floor(secondsAgo / SECONDS_PER_HOUR);
    minutesAgo = minutesAgo % MINUTES_PER_HOUR;
    if (hoursAgo < HOURS_PER_DAY) {
      let s = hoursAgo.toString() + maybeMakePlural(' hour', hoursAgo);
      if (minutesAgo > 0) {
        s += ' and ' + minutesAgo.toString() +
            maybeMakePlural(' minute', minutesAgo);
      }
      s += ' ago';
      return s;
    }

    // Days ago.
    let daysAgo = Math.floor(secondsAgo / SECONDS_PER_DAY);
    if (daysAgo < DAYS_PER_WEEK) {
      return daysAgo.toString() + maybeMakePlural(' day', daysAgo) + ' ago';
    }

    // Weeks ago. There's an awkward gap to bridge where 4 weeks can have
    // elapsed but not quite 1 month. Be sure to use weeks to report that.
    let weeksAgo = Math.floor(secondsAgo / SECONDS_PER_WEEK);
    let monthsAgo = Math.floor(secondsAgo / SECONDS_PER_MONTH);
    if (monthsAgo < 1) {
      return 'over ' + weeksAgo.toString() +
          maybeMakePlural(' week', weeksAgo) + ' ago';
    }

    // Months ago.
    let yearsAgo = Math.floor(secondsAgo / SECONDS_PER_YEAR);
    if (yearsAgo < 1) {
      return 'over ' + monthsAgo.toString() +
          maybeMakePlural(' month', monthsAgo) + ' ago';
    }

    // Years ago.
    return 'over ' + yearsAgo.toString() + maybeMakePlural(' year', yearsAgo) +
        ' ago';
  }
/**
   * Converts a |secondsAgo| last-active time to a user friendly string.
   * @param {number} secondsAgo The amount of time since the tab was active.
   * @return {string} An English string representing the last active time.
   */
Converts a |secondsAgo| last-active time to a user friendly string.
@param {number} secondsAgo The amount of time since the tab was active.
@return {string} An English string representing the last active time.
Converts a |secondsAgo| last - active time to a user friendly string . @param { number } secondsAgo The amount of time since the tab was active . @return { string } An English string representing the last active time .
function lastActiveToString(secondsAgo) {
    const SECONDS_PER_MINUTE = 60;
    const MINUTES_PER_HOUR = 60;
    const SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
    const HOURS_PER_DAY = 24;
    const SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
    const DAYS_PER_WEEK = 7;
    const SECONDS_PER_WEEK = SECONDS_PER_DAY * DAYS_PER_WEEK;
    const SECONDS_PER_MONTH = SECONDS_PER_DAY * 30.5;
    const SECONDS_PER_YEAR = SECONDS_PER_DAY * 365;
    if (secondsAgo < SECONDS_PER_MINUTE)
      return 'just now';
    let minutesAgo = Math.floor(secondsAgo / SECONDS_PER_MINUTE);
    if (minutesAgo < MINUTES_PER_HOUR) {
      return minutesAgo.toString() + maybeMakePlural(' minute', minutesAgo) +
          ' ago';
    }
    let hoursAgo = Math.floor(secondsAgo / SECONDS_PER_HOUR);
    minutesAgo = minutesAgo % MINUTES_PER_HOUR;
    if (hoursAgo < HOURS_PER_DAY) {
      let s = hoursAgo.toString() + maybeMakePlural(' hour', hoursAgo);
      if (minutesAgo > 0) {
        s += ' and ' + minutesAgo.toString() +
            maybeMakePlural(' minute', minutesAgo);
      }
      s += ' ago';
      return s;
    }
    let daysAgo = Math.floor(secondsAgo / SECONDS_PER_DAY);
    if (daysAgo < DAYS_PER_WEEK) {
      return daysAgo.toString() + maybeMakePlural(' day', daysAgo) + ' ago';
    }
    let weeksAgo = Math.floor(secondsAgo / SECONDS_PER_WEEK);
    let monthsAgo = Math.floor(secondsAgo / SECONDS_PER_MONTH);
    if (monthsAgo < 1) {
      return 'over ' + weeksAgo.toString() +
          maybeMakePlural(' week', weeksAgo) + ' ago';
    }
    let yearsAgo = Math.floor(secondsAgo / SECONDS_PER_YEAR);
    if (yearsAgo < 1) {
      return 'over ' + monthsAgo.toString() +
          maybeMakePlural(' month', monthsAgo) + ' ago';
    }
    return 'over ' + yearsAgo.toString() + maybeMakePlural(' year', yearsAgo) +
        ' ago';
  }
function lastActiveToString ( secondsAgo ) { const SECONDS_PER_MINUTE = 60 ; const MINUTES_PER_HOUR = 60 ; const SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR ; const HOURS_PER_DAY = 24 ; const SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY ; const DAYS_PER_WEEK = 7 ; const SECONDS_PER_WEEK = SECONDS_PER_DAY * DAYS_PER_WEEK ; const SECONDS_PER_MONTH = SECONDS_PER_DAY * 30.5 ; const SECONDS_PER_YEAR = SECONDS_PER_DAY * 365 ; if ( secondsAgo < SECONDS_PER_MINUTE ) return 'just now' ; let minutesAgo = Math . floor ( secondsAgo / SECONDS_PER_MINUTE ) ; if ( minutesAgo < MINUTES_PER_HOUR ) { return minutesAgo . toString ( ) + maybeMakePlural ( ' minute' , minutesAgo ) + ' ago' ; } let hoursAgo = Math . floor ( secondsAgo / SECONDS_PER_HOUR ) ; minutesAgo = minutesAgo % MINUTES_PER_HOUR ; if ( hoursAgo < HOURS_PER_DAY ) { let s = hoursAgo . toString ( ) + maybeMakePlural ( ' hour' , hoursAgo ) ; if ( minutesAgo > 0 ) { s += ' and ' + minutesAgo . toString ( ) + maybeMakePlural ( ' minute' , minutesAgo ) ; } s += ' ago' ; return s ; } let daysAgo = Math . floor ( secondsAgo / SECONDS_PER_DAY ) ; if ( daysAgo < DAYS_PER_WEEK ) { return daysAgo . toString ( ) + maybeMakePlural ( ' day' , daysAgo ) + ' ago' ; } let weeksAgo = Math . floor ( secondsAgo / SECONDS_PER_WEEK ) ; let monthsAgo = Math . floor ( secondsAgo / SECONDS_PER_MONTH ) ; if ( monthsAgo < 1 ) { return 'over ' + weeksAgo . toString ( ) + maybeMakePlural ( ' week' , weeksAgo ) + ' ago' ; } let yearsAgo = Math . floor ( secondsAgo / SECONDS_PER_YEAR ) ; if ( yearsAgo < 1 ) { return 'over ' + monthsAgo . toString ( ) + maybeMakePlural ( ' month' , monthsAgo ) + ' ago' ; } return 'over ' + yearsAgo . toString ( ) + maybeMakePlural ( ' year' , yearsAgo ) + ' ago' ; }
Converts a |secondsAgo| last-active time to a user friendly string.
Converts a |secondsAgo| last - active time to a user friendly string .
// These constants aren't perfect, but close enough. // Seconds ago. // Minutes ago. // Hours and minutes and ago. // Days ago. // Weeks ago. There's an awkward gap to bridge where 4 weeks can have // elapsed but not quite 1 month. Be sure to use weeks to report that. // Months ago. // Years ago.