"use strict";
exports.__esModule = true;
exports.isOnlyOneDateInRange = exports.isDateRange = exports.getMonthTitle = exports.formatDate = exports.parseDate = exports.DATE_FORMAT = void 0;
var tslib_1 = require("tslib");
var date_fns_1 = require("date-fns");
var ru_1 = (0, tslib_1.__importDefault)(require("date-fns/locale/ru"));
var type_guards_1 = require("./type-guards");
exports.DATE_FORMAT = 'dd.MM.yyyy';
var parseDate = function (date) {
    return (0, date_fns_1.parse)(date, exports.DATE_FORMAT, new Date(), { locale: ru_1["default"] });
};
exports.parseDate = parseDate;
var formatDate = function (date, dateFormat) {
    if (dateFormat === void 0) { dateFormat = exports.DATE_FORMAT; }
    return (0, date_fns_1.format)(date, dateFormat);
};
exports.formatDate = formatDate;
var getMonthTitle = function (date) {
    return (0, date_fns_1.format)(date, 'LLLL', { locale: ru_1["default"] });
};
exports.getMonthTitle = getMonthTitle;
var isDateRange = function (value) {
    return Array.isArray(value) &&
        value.length === 2 &&
        value.every(function (date) { return date instanceof Date || !(0, type_guards_1.isDefined)(date); });
};
exports.isDateRange = isDateRange;
var isOnlyOneDateInRange = function (range) {
    return Boolean((range[0] && !range[1]) || (!range[0] && range[1]));
};
exports.isOnlyOneDateInRange = isOnlyOneDateInRange;
