徐总多门店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
828 B

5 months ago
var staticDayTime = require('./staticDayTime')
var staticStrFirst = require('./staticStrFirst')
var staticStrLast = require('./staticStrLast')
var helperGetDateTime = require('./helperGetDateTime')
var getWhatMonth = require('./getWhatMonth')
var toStringDate = require('./toStringDate')
var isValidDate = require('./isValidDate')
/**
* 返回某个月份的天数
*
* @param {Date} date 日期或数字
* @param {Number} offset (默认当月)前几个月后几个月
* @return {Number}
*/
function getDayOfMonth (date, month) {
date = toStringDate(date)
if (isValidDate(date)) {
return Math.floor((helperGetDateTime(getWhatMonth(date, month, staticStrLast)) - helperGetDateTime(getWhatMonth(date, month, staticStrFirst))) / staticDayTime) + 1
}
return NaN
}
module.exports = getDayOfMonth