function formatISO9075(dirtyDate, dirtyOptions) {
  if (arguments.length < 1) {
    throw new TypeError("1 argument required, but only ".concat(arguments.length, " present"));
  }

  var originalDate = __WEBPACK_IMPORTED_MODULE_0__toDate_index_js__["a" /* default */](dirtyDate);

  if (!__WEBPACK_IMPORTED_MODULE_1__isValid_index_js__["a" /* default */](originalDate)) {
    throw new RangeError('Invalid time value');
  }

  var options = dirtyOptions || {};
  var format = options.format == null ? 'extended' : String(options.format);
  var representation = options.representation == null ? 'complete' : String(options.representation);

  if (format !== 'extended' && format !== 'basic') {
    throw new RangeError("format must be 'extended' or 'basic'");
  }

  if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {
    throw new RangeError("representation must be 'date', 'time', or 'complete'");
  }

  var result = '';
  var dateDelimiter = format === 'extended' ? '-' : '';
  var timeDelimiter = format === 'extended' ? ':' : ''; // Representation is either 'date' or 'complete'

  if (representation !== 'time') {
    var day = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getDate(), 2);
    var month = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getMonth() + 1, 2);
    var year = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getFullYear(), 4); // yyyyMMdd or yyyy-MM-dd.

    result = "".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);
  } // Representation is either 'time' or 'complete'


  if (representation !== 'date') {
    var hour = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getHours(), 2);
    var minute = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getMinutes(), 2);
    var second = __WEBPACK_IMPORTED_MODULE_2__lib_addLeadingZeros_index_js__["a" /* default */](originalDate.getSeconds(), 2); // If there's also date, separate it with time with a space

    var separator = result === '' ? '' : ' '; // HHmmss or HH:mm:ss.

    result = "".concat(result).concat(separator).concat(hour).concat(timeDelimiter).concat(minute).concat(timeDelimiter).concat(second);
  }

  return result;
}
@name formatISODuration
@category Common Helpers
@summary Format a duration object according as ISO 8601 duration string

@description
Format a duration object according to the ISO 8601 duration standard (https://www.digi.com/resources/documentation/digidocs/90001437-13/reference/r_iso_8601_duration_format.htm)

@param {Duration} duration - the duration to format

@returns {String} The ISO 8601 duration string
@throws {TypeError} Requires 1 argument
@throws {Error} Argument must be an object

@example
// Format the given duration as ISO 8601 string
formatISODuration({
  years: 39,
  months: 2,
  days: 20,
  hours: 7,
  minutes: 5,
  seconds: 0
})
//=> 'P39Y2M20DT0H0M0S'