function parseDataSource(months, locale) {
  var dataSource = {};

  for (var i = 0; i < months.length; i++) {
    var year = months[i].getFullYear();
    var month = months[i].getMonth();

    if (!dataSource[year]) {
      dataSource[year] = {
        value: year,
        label: year,
        children: [{
          value: month,
          label: locale === null || locale === void 0 ? void 0 : locale.months[month]
        }]
      };
    } else {
      dataSource[year].children.push({
        value: month,
        label: locale === null || locale === void 0 ? void 0 : locale.months[month]
      });
    }
  }

  return dataSource;
}

export default parseDataSource;