count-days-in-month
Version:
Get the number of days in a given month
53 lines (35 loc) • 1.78 kB
Markdown
# count-days-in-month
[](https://www.npmjs.com/package/count-days-in-month)
[](https://github.com/shinnn/count-days-in-month/releases)
[](https://travis-ci.org/shinnn/count-days-in-month)
[](https://coveralls.io/r/shinnn/count-days-in-month)
[](https://david-dm.org/shinnn/count-days-in-month)
[](https://david-dm.org/shinnn/count-days-in-month#info=devDependencies)
Get the number of days in a given month
```javascript
countDaysInMonth(2016, 11); //=> 31
countDaysInMonth(2016, 8); //=> 30
```
## Installation
### Package managers
#### [npm](https://www.npmjs.com/)
```
npm install count-days-in-month
```
#### [bower](https://bower.io/)
```
bower install count-days-in-month
```
## API
### countDaysInMonth(*fullYear*, *zerBasedMonth*)
*fullYear*: `Number` of [full year](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear), for example `2016`
*zeroBasedMonth*: `Number` of month, zero based (`0`, `1`, ... `11`)
Return: `Number` of days
It returns a number of days in the month, considering the year is whether a leap year or not.
```javascript
countDaysInMonth(2015, 1); //=> 28
countDaysInMonth(2016, 1); //=> 29
```
## License
Copyright (c) 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).