feat(cp排行榜): 倒计时暂时设置成2月19早上5点
This commit is contained in:
parent
85c693924f
commit
96ad884191
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user