month-calculator
v1.2.3
Published
A plugin for month calculator, get months date from start date to end date
Downloads
80
Readme
month-calculator
A plugin for month date calculator , 中文
Install
npm install month-calculator --save
Features
- 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-DD
endDate
- the end date formatted likeYYYY-MM-DD
Method
getTotal
- get the total months fromstartDate
toendDate
getToday
- if today's date is betweenstartDate
andendDate
, will return an Object{ monthIndex, date }
, and themonthIndex
is 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-DD
year
- date formattedYYYY
month
- date formattedMM
day
- date formattedDD
weekday
- weekday from0
to6
week
- Chinese weekday日一二三四五六
isPrevMonth
- if it is previous month date, will betrue
isNextMonth
- if it is next month date, will betrue
disabled
- if it isisPrevMonth
、isNextMonth
or current month disabled date(not betweenstartDate
toendDate
), will betrue