{"size": 609, "ext": "js", "max_stars_repo_path": "src/services/utilities.js", "max_stars_repo_name": "fabian0896/lunch-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/services/utilities.js", "max_issues_repo_name": "fabian0896/lunch-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/services/utilities.js", "max_forks_repo_name": "fabian0896/lunch-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.5555555556, "max_line_length": 56, "alphanum_fraction": 0.6699507389}
import {
  startOfMonth,
  endOfMonth,
  startOfDay,
  endOfDay,
  getDate,
  setDate,
} from 'date-fns';

// eslint-disable-next-line import/prefer-default-export
export const getCutDayRange = (date, cutDay = 15) => {
  const actualDay = getDate(date);

  const rangeDate = [];

  if (actualDay <= cutDay) {
    rangeDate[0] = startOfMonth(date);
    const finishCutDay = setDate(date, cutDay);
    rangeDate[1] = endOfDay(finishCutDay);
  } else {
    const afterCutDay = setDate(date, cutDay + 1);
    rangeDate[0] = startOfDay(afterCutDay);
    rangeDate[1] = endOfMonth(date);
  }
  return rangeDate;
};
