UNPKG

@antmjs/vantui

Version:

一套适用于Taro3及React的vantui组件库

47 lines (46 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compareMonth = compareMonth; exports.getButtonDisabled = getButtonDisabled; exports.getMonthEndDay = getMonthEndDay; exports.getMonths = getMonths; /* eslint-disable */ function getMonthEndDay(year, month) { return 32 - new Date(year, month - 1, 32).getDate(); } function compareMonth(date1, date2) { date1 = new Date(date1); date2 = new Date(date2); var year1 = date1.getFullYear(); var year2 = date2.getFullYear(); var month1 = date1.getMonth(); var month2 = date2.getMonth(); if (year1 === year2) { return month1 === month2 ? 0 : month1 > month2 ? 1 : -1; } return year1 > year2 ? 1 : -1; } function getMonths(minDate, maxDate) { var months = []; var cursor = new Date(minDate); cursor.setDate(1); do { months.push(cursor.getTime()); cursor.setMonth(cursor.getMonth() + 1); } while (compareMonth(cursor, new Date(maxDate)) !== 1); return months; } function getButtonDisabled(type, currentDate) { if (currentDate == null) { return true; } if (type === 'range') { return !currentDate[0] || !currentDate[1]; } if (type === 'multiple') { return !currentDate.length; } return !currentDate; }