// Adds leading zero to month/day if necessary, returns 'YYYY' if type = 'year',
// 'YYYY-MM' if 'month' and 'YYYY-MM-DD' if 'date'
import pad from "./pad.mjs";
export default ((dateString, type) => {
  const [year, month = 1, date = 1] = dateString.split('-');
  return "".concat(year, "-").concat(pad(month), "-").concat(pad(date)).substr(0, {
    date: 10,
    month: 7,
    year: 4
  }[type]);
});
//# sourceMappingURL=sanitizeDateString.mjs.map