- 新增 server/:Node + Express + SQLite + node-cron 实现登录、纪念日 CRUD 和定时订阅消息推送 - 新增 .gitea/workflows/deploy.yml:推送即触发群晖 Docker 部署,监听 15002 - utils/api.js:自动按 envVersion 切换本地/线上 BASE_URL - app.js 与 add-anniversary.js 移除 wx.cloud 调用,改走自建后端 - cloudfunctions/ 暂保留以便回滚 - 一并提交此前未入库的首页 / 设置页 / 日历 / 万年历等改造 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -103,9 +103,28 @@ function parseDate(dateString) {
|
||||
return new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, parseInt(parts[2]))
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定月日的下一次发生日期(今年或明年)
|
||||
* @param {Number} month - 月份 (1-12)
|
||||
* @param {Number} day - 日 (1-31)
|
||||
* @returns {{ date: Date, daysUntil: Number }}
|
||||
*/
|
||||
function getNextOccurrence(month, day) {
|
||||
const today = new Date()
|
||||
const currentYear = today.getFullYear()
|
||||
let date = new Date(currentYear, month - 1, day)
|
||||
let daysUntil = getDaysUntil(date)
|
||||
if (daysUntil < 0) {
|
||||
date = new Date(currentYear + 1, month - 1, day)
|
||||
daysUntil = getDaysUntil(date)
|
||||
}
|
||||
return { date, daysUntil }
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatDate,
|
||||
getDaysUntil,
|
||||
getNextOccurrence,
|
||||
isToday,
|
||||
isPast,
|
||||
isUpcoming,
|
||||
|
||||
Reference in New Issue
Block a user