1.2.3 • Published 8 years ago
month-calculator v1.2.3
month-calculator
A plugin for month date calculator , 中文
Install
npm install month-calculator --saveFeatures
- Highly customizable
- No dependence on UI, You can design by yourself
- Support browser、nodejs、miniProgram(小程序)
Usage
var oMonth = new MonthCalculator({
startDate: '2017-07-17',
endDate: '2018-08-18'
});
var months = oMonth.getTotal();
console.log(months);Parameter
startDate- the start date formatted likeYYYY-MM-DDendDate- the end date formatted likeYYYY-MM-DD
Method
getTotal- get the total months fromstartDatetoendDategetToday- if today's date is betweenstartDateandendDate, will return an Object{ monthIndex, date }, and themonthIndexis today's month index in total result, otherwise will returnundefined
Result
After use getTotal method will return the result structure below
[
{
title: '2017-07',
dates: [
{
date: '2017-06-25',
year: '2017',
month: '06',
day: '25',
disabled: true,
isPrevMonth: true,
week: '日',
weekday: 0
}
...
]
}
...
]Result date properties
date- total date formattedYYYY-MM-DDyear- date formattedYYYYmonth- date formattedMMday- date formattedDDweekday- weekday from0to6week- Chinese weekday日一二三四五六isPrevMonth- if it is previous month date, will betrueisNextMonth- if it is next month date, will betruedisabled- if it isisPrevMonth、isNextMonthor current month disabled date(not betweenstartDatetoendDate), will betrue
