From 39fe9b7dcc155606d76c4fc0b2a42cdfae9114bc Mon Sep 17 00:00:00 2001 From: Yifan Liu Date: Tue, 7 Feb 2023 02:32:49 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E4=BA=86=E5=90=84?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E5=8C=BA=E7=9A=84YJ=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E8=B0=83=E6=95=B4=E4=BA=86YJ=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/Utils.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/MaaWpfGui/Helper/Utils.cs b/src/MaaWpfGui/Helper/Utils.cs index 958848be5f..845313c68e 100644 --- a/src/MaaWpfGui/Helper/Utils.cs +++ b/src/MaaWpfGui/Helper/Utils.cs @@ -62,15 +62,18 @@ namespace MaaWpfGui public static string ClientType { get => _clientType; set => _clientType = value; } - private static readonly Dictionary _clientTypeTimeOffsetMap = new Dictionary + // YJ历每一天从4点开始,计算日期的时候第二天4点前仍然算作前一天 + private static readonly int YJDayStartHour = 4; + + private static readonly Dictionary _clientTypeTimezone = new Dictionary { - { string.Empty, 4 }, - { "Official", 4 }, - { "Bilibili", 4 }, - { "txwy", 4 }, - { "YoStarEN", 4 }, - { "YoStarJP", 5 }, - { "YoStarKR", 4 }, + { string.Empty, 8 }, + { "Official", 8 }, + { "Bilibili", 8 }, + { "txwy", 8 }, + { "YoStarEN", -7 }, + { "YoStarJP", 9 }, + { "YoStarKR", 9 }, }; /// @@ -79,7 +82,7 @@ namespace MaaWpfGui /// yj历时间 public static DateTime GetYJTimeNow() { - return DateTime.UtcNow.AddHours(_clientTypeTimeOffsetMap[ClientType]); + return ToYJTime(DateTime.UtcNow); } /// @@ -116,7 +119,7 @@ namespace MaaWpfGui /// yj历格式的时间 public static DateTime ToYJTime(DateTime dt) { - return dt.AddHours(_clientTypeTimeOffsetMap[ClientType]); + return dt.AddHours(_clientTypeTimezone[ClientType] - YJDayStartHour); } private static readonly JObject _itemList = new JObject();