import { buildIsoDate } from '../buildIsoDate';
/**
 * глубина сравнивания, даты могут быть равны по году, но разные по месяцу, и т.д.
 */
export var DateCompareDeep;
(function (DateCompareDeep) {
    DateCompareDeep[DateCompareDeep["Year"] = 0] = "Year";
    DateCompareDeep[DateCompareDeep["Month"] = 1] = "Month";
    DateCompareDeep[DateCompareDeep["Day"] = 2] = "Day";
    DateCompareDeep[DateCompareDeep["Hour"] = 3] = "Hour";
    DateCompareDeep[DateCompareDeep["Minute"] = 4] = "Minute";
    DateCompareDeep[DateCompareDeep["Second"] = 5] = "Second";
})(DateCompareDeep || (DateCompareDeep = {}));
export const buildDateByDeep = (date, deep) => buildIsoDate({
    year: date.getUTCFullYear(),
    month: deep > DateCompareDeep.Year ? date.getUTCMonth() + 1 : undefined,
    day: deep > DateCompareDeep.Month ? date.getUTCDate() : undefined,
    hour: deep > DateCompareDeep.Day ? date.getUTCHours() : undefined,
    minute: deep > DateCompareDeep.Hour ? date.getUTCMinutes() : undefined,
    second: deep > DateCompareDeep.Minute ? date.getUTCSeconds() : undefined,
});
/**
 * утилита занимающаяся числовым сравнением дат на НЕ вхождение даты в промежуток между А и B
 */
const checkDateOnOutOfRange = ({ date, dateA, dateB, }) => !((dateA >= date && date >= dateB) || (dateB >= date && date >= dateA));
/**
 * утилита проверки даты на НЕ вхождение в указанный диапазон между A и B, с учетом глубины сравнения
 */
export const isDateOutOfRange = ({ date, dateA, dateB, deep = DateCompareDeep.Second, }) => {
    if (deep === DateCompareDeep.Second) {
        return checkDateOnOutOfRange({ date, dateA, dateB });
    }
    return checkDateOnOutOfRange({
        date: buildDateByDeep(date, deep),
        dateA: buildDateByDeep(dateA, deep),
        dateB: buildDateByDeep(dateB, deep),
    });
};
