From ed3c47d733568473707189594a6c99b0b7140da3 Mon Sep 17 00:00:00 2001 From: kilikilikid Date: Wed, 2 Dec 2020 22:44:27 +0000 Subject: [PATCH] Update JDDouK.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 粗暴地解决设备时区问题,让时间先统一到UTC,然后+8小时到中国时间。 --- Scripts/JDDouK.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/JDDouK.js b/Scripts/JDDouK.js index 75afadd..7c9d35d 100644 --- a/Scripts/JDDouK.js +++ b/Scripts/JDDouK.js @@ -141,6 +141,7 @@ module.exports = template;`; Keychain.set(this.CACHE_KEY, JSON.stringify(this.rangeTimer)); } const date = new Date(); + date.setHours(date.getHours() + date.getTimezoneOffset()/60 + 8); const year = date.getFullYear(); let month = date.getMonth() + 1; month = month >= 10 ? month : `0${month}`; @@ -225,6 +226,7 @@ module.exports = template;`; let i = dayNumber; do { const today = new Date(); + today.setHours(today.getHours() + today.getTimezoneOffset()/60 + 8); const year = today.getFullYear(); const targetday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24 * i; today.setTime(targetday_milliseconds); //注意,这行是关键代码