NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/xe-utils/methods/date/getDayOfMonth.js
2023-09-14 14:47:11 +08:00

28 lines
843 B
Java

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