import type {
    MonthSelectInitialGeneratorType
} from "./type";

export const dateSelect = ({
    dateRange,
    variant,
    date
}: MonthSelectInitialGeneratorType): Date => {
    if(variant === "single" && date) {
        return date;
    }

    if(variant === "range" && dateRange && (dateRange.start || dateRange.end)) {
        if(dateRange.start) return dateRange.start;
        if(dateRange.end) return dateRange.end;
    }

    return new Date();
};
