feat(倒计时): 将周一刷新改成沙特的周一早上6点
This commit is contained in:
parent
4dc912e4ab
commit
28aae509e1
@ -797,17 +797,18 @@ const Minutes = ref(0)
|
||||
const Second = ref(0)
|
||||
let timer = null
|
||||
|
||||
const getNextMonday = () => {
|
||||
// 获取沙特下周一早上六点的时间戳
|
||||
const getNextMondayInSaudi = () => {
|
||||
const now = new Date()
|
||||
const day = now.getDay() //0(周日)-6(周六)
|
||||
const utcDay = now.getUTCDay() //获取UTC星期几,0(周日)-6(周六)
|
||||
|
||||
// 计算到下周一的所需天数
|
||||
const daysToAdd = day === 1 ? 7 : (1 + 7 - day) % 7
|
||||
const nextMonday = new Date(now) //以当前时间为基准,而不是重新获取时间
|
||||
const daysToAdd = utcDay === 1 ? 7 : (1 + 7 - utcDay) % 7
|
||||
const nextMondayUTC = new Date(now) //以当前UTC时间为基准,而不是重新获取
|
||||
|
||||
nextMonday.setDate(now.getDate() + daysToAdd) //增加到下周一那天
|
||||
nextMonday.setHours(0, 0, 0, 0) // 设置为下周一当天00:00:00.000
|
||||
return nextMonday.getTime() //得到下周一00:00:00.000的时间戳
|
||||
nextMondayUTC.setUTCDate(now.getUTCDate() + daysToAdd) //增加到下周一那天
|
||||
nextMondayUTC.setUTCHours(3, 0, 0, 0) // 设置为沙特下周一当天早上6点(北京时间3点)
|
||||
return nextMondayUTC.getTime() //得到下周一00:00:00.000的时间戳
|
||||
}
|
||||
|
||||
// 时间格式化为2位
|
||||
@ -815,7 +816,7 @@ const formatTime = (value) => {
|
||||
return value < 10 ? `0${value}` : value
|
||||
}
|
||||
|
||||
const targetTime = ref(getNextMonday()) // 闭包保存目标时间 (核心修正)
|
||||
const targetTime = ref(getNextMondayInSaudi()) // 闭包保存目标时间 (核心修正)
|
||||
|
||||
// 更新倒计时
|
||||
const getCountdown = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user