1.2.3 • Published 6 years ago

month-calculator v1.2.3

Weekly downloads
53
License
MIT
Repository
github
Last release
6 years ago

month-calculator

NPM

Build Status Language License

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 like YYYY-MM-DD
  • endDate - the end date formatted like YYYY-MM-DD

Method

  • getTotal - get the total months from startDate to endDate
  • getToday - if today's date is between startDate and endDate, will return an Object { monthIndex, date }, and the monthIndex is today's month index in total result, otherwise will return undefined

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 formatted YYYY-MM-DD
  • year - date formatted YYYY
  • month - date formatted MM
  • day - date formatted DD
  • weekday - weekday from 0 to 6
  • week - Chinese weekday 日一二三四五六
  • isPrevMonth - if it is previous month date, will be true
  • isNextMonth - if it is next month date, will be true
  • disabled - if it is isPrevMonthisNextMonth or current month disabled date(not between startDate to endDate), will be true

Examples

License

license

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.0

6 years ago