diff --git a/src/views/Ranking/Couple/Ranking.vue b/src/views/Ranking/Couple/Ranking.vue index 17670e4..e63717d 100644 --- a/src/views/Ranking/Couple/Ranking.vue +++ b/src/views/Ranking/Couple/Ranking.vue @@ -335,7 +335,7 @@ const startCountdown = () => { monthlyCountdownTimer = setInterval(getMonthlyCountdown, 1000) } -// 获取下个月1号早上5点的北京时间 +// 获取2月19号早上5点的北京时间 const getNextMonthFirstInBeijing = () => { const now = new Date() @@ -346,24 +346,21 @@ const getNextMonthFirstInBeijing = () => { const date = beijingTime.getUTCDate() const hour = beijingTime.getUTCHours() - // 确定目标月份 + // 确定目标年份 - 如果当前时间在本年度2月19日之前,则目标是今年2月19日;否则是明年2月19日 let targetYear = year - let targetMonth = month - if (date === 1 && hour < 5) { - // 如果今天是1号且还没过5点,目标就是本月1号5点 - } else { - // 否则目标是下个月1号 - targetMonth = month + 1 - if (targetMonth > 11) { - targetMonth = 0 - targetYear++ - } + // 检查是否已经超过今年的2月19日 + if (month > 1 || (month === 1 && date > 19) || (month === 1 && date === 19 && hour >= 5)) { + // 如果当前时间已经超过今年的2月19日5点,则目标是明年的2月19日 + targetYear = year + 1 } - // 创建代表北京时间的UTC时间戳 + // 目标月份固定为2月(月份索引为1) + const targetMonth = 1 // 2月的索引是1(0是1月) + + // 创建代表北京时间的UTC时间戳 - 2月19号而不是1号 // 使用Date.UTC创建代表"北京时间"的时间戳 - const targetDateAsBeijing = Date.UTC(targetYear, targetMonth, 1, 5, 0, 0) - 8 * 60 * 60 * 1000 + const targetDateAsBeijing = Date.UTC(targetYear, targetMonth, 19, 5, 0, 0) - 8 * 60 * 60 * 1000 return targetDateAsBeijing }