MCPcopy Create free account
hub / github.com/chavyleung/scripts / checkLastDayOfMonth

Function checkLastDayOfMonth

zsfc/zsfc.js:325–333  ·  view source on GitHub ↗

* 判断今天的日期和本月剩余天数是否小于N天。 * * @param {number} N - 传入数字,代表本月最后N天 * @returns {boolean} - 返回匹布尔值

(N)

Source from the content-addressed store, hash-verified

323 * @returns {boolean} - 返回匹布尔值
324 */
325function checkLastDayOfMonth(N) {
326 // 初始化一个表示当前日期和时间的 today 对象
327 let today = new Date();
328
329 // 获取当前月份的最后一天的日期
330 let day = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate();
331
332 return (day - today.getDate()) < N; // 月底最后3天的计算方式是小于N而不能有等于
333}
334
335/**
336 * 从输入字符串中提取指定关键字的值。

Callers 1

zsfc.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected