export var WEEKS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
export var MONTHS = [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec',
];
var TODAY = new Date();
export var THIS_YEAR = TODAY.getFullYear();
export var THIS_MONTH = TODAY.getMonth();
export var THIS_DAY = TODAY.getDate();
export var isLeapYear = function (year) {
    if (year % 4 === 0 && year % 100 !== 0) {
        return true;
    }
    else if (year % 400 === 0) {
        return true;
    }
    return false;
};
export var getMonthDays = function (year, month) {
    if (year === void 0) { year = THIS_YEAR; }
    if (month === void 0) { month = THIS_MONTH; }
    var day = year && isLeapYear(year) ? 29 : 28;
    return [31, day, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};
export var getWeekday = function (year, month, date) {
    if (year === void 0) { year = THIS_YEAR; }
    if (month === void 0) { month = THIS_MONTH; }
    if (date === void 0) { date = THIS_DAY; }
    return new Date(year, month, date).getDay();
};
export var getMonthDaysArray = function (date) {
    if (date === void 0) { date = TODAY; }
    var year = date.getFullYear();
    var month = date.getMonth();
    var dayArrays = [];
    var days = getMonthDays(year, month);
    var _a = getPrevMonthAndYear(year, month), preYear = _a[0], preMonth = _a[1];
    var preDays = getMonthDays(preYear, preMonth);
    var thisMonthFirstDayInWeek = getWeekday(year, month, 1);
    for (var i = 0; i < thisMonthFirstDayInWeek; i++) {
        var day = preDays - thisMonthFirstDayInWeek + i + 1;
        dayArrays.push({
            label: day,
            date: new Date(preYear, preMonth, day),
            isThisMonth: false,
        });
    }
    for (var i = 1; i <= days; i++) {
        dayArrays.push({
            label: i,
            date: new Date(year, month, i),
            isThisMonth: true,
        });
    }
    for (var i = 1; i <= 42 - days - thisMonthFirstDayInWeek; i++) {
        dayArrays.push({
            label: i,
            date: new Date(year, month + 1, i),
            isThisMonth: false,
        });
    }
    return dayArrays;
};
export var isSameDate = function (dateA, dateB) {
    var dateAYear = dateA.getFullYear();
    var dateAMonth = dateA.getMonth();
    var dateADate = dateA.getDate();
    var dateBYear = dateB.getFullYear();
    var dateBMonth = dateB.getMonth();
    var dateBDate = dateB.getDate();
    return dateAYear === dateBYear && dateAMonth === dateBMonth && dateADate === dateBDate;
};
export var isToday = function (date) {
    return isSameDate(new Date(), date);
};
export var isDate = function (date) {
    var isPrototypeDate = Object.prototype.toString.call(date) === '[object Date]';
    var isValidDate = date && !Number.isNaN(date.valueOf());
    return isPrototypeDate && isValidDate;
};
export var getPrevMonthDate = function (date) {
    if (date === void 0) { date = TODAY; }
    var month = date.getMonth();
    var year = date.getFullYear();
    var prevMonth = month > 0 ? month - 1 : 11;
    var prevYear = month > 0 ? year : year - 1;
    return new Date(prevYear, prevMonth, date.getDate());
};
export var getPrevMonthAndYear = function (year, month) {
    if (year === void 0) { year = THIS_YEAR; }
    if (month === void 0) { month = THIS_MONTH; }
    var prevMonth = month > 0 ? month - 1 : 11;
    var prevYear = month > 0 ? year : year - 1;
    return [prevYear, prevMonth];
};
export var getNextMonthDate = function (date) {
    if (date === void 0) { date = TODAY; }
    var month = date.getMonth();
    var year = date.getFullYear();
    var nextMonth = month < 11 ? month + 1 : 0;
    var nextYear = month < 11 ? year : year + 1;
    return new Date(nextYear, nextMonth, date.getDate());
};
export var getPrevYearDate = function (date) {
    if (date === void 0) { date = TODAY; }
    return new Date(date.getFullYear() - 1, date.getMonth(), date.getDate());
};
export var getNextYearDate = function (date) {
    if (date === void 0) { date = TODAY; }
    return new Date(date.getFullYear() + 1, date.getMonth(), date.getDate());
};
//# sourceMappingURL=utils.js.map