function format (firstDate, secondDate, config) {

  checkLocale(config.locale);

  // Handling input arguments.
  // -----

  if (!firstDate) {
    throw new Error('Missing first date');
  }

  if (!secondDate) {
    throw new Error('Missing second date');
  }

  // Calculating.
  // -----

  var difference = getDifference(firstDate, secondDate);
  var parts = [];
  difference.some(function (unit) {
    var name = unit[0];
    var value = unit[1];
    if (value > 0) {
      parts.push(pluralize(name, value, config));
    }
    if (parts.length >= config.span) {
      // Breaking the loop.
      return true;
    }
  });

  // Returning the string value.
  return parts.join(config.delimiter);
}
/**
 * Returns difference between two dates as a text string.
 *
 * @param {Date} firstDate
 * @param {Date} secondDate
 * @param {object} config
 *
 * @returns {string}
 */
Returns difference between two dates as a text string.

@returns {string}
Returns difference between two dates as a text string . @returns { string }
function format (firstDate, secondDate, config) {
  checkLocale(config.locale);
  if (!firstDate) {
    throw new Error('Missing first date');
  }
  if (!secondDate) {
    throw new Error('Missing second date');
  }
  var difference = getDifference(firstDate, secondDate);
  var parts = [];
  difference.some(function (unit) {
    var name = unit[0];
    var value = unit[1];
    if (value > 0) {
      parts.push(pluralize(name, value, config));
    }
    if (parts.length >= config.span) {
      return true;
    }
  });
  return parts.join(config.delimiter);
}
function format ( firstDate , secondDate , config ) { checkLocale ( config . locale ) ; if ( ! firstDate ) { throw new Error ( 'Missing first date' ) ; } if ( ! secondDate ) { throw new Error ( 'Missing second date' ) ; } var difference = getDifference ( firstDate , secondDate ) ; var parts = [ ] ; difference . some ( function ( unit ) { var name = unit [ 0 ] ; var value = unit [ 1 ] ; if ( value > 0 ) { parts . push ( pluralize ( name , value , config ) ) ; } if ( parts . length >= config . span ) { return true ; } } ) ; return parts . join ( config . delimiter ) ; }
Returns difference between two dates as a text string.
Returns difference between two dates as a text string .
// Handling input arguments. // ----- // Calculating. // ----- // Breaking the loop. // Returning the string value.