diff --git a/src/MaaWpfGui/Helper/Utils.cs b/src/MaaWpfGui/Helper/Utils.cs new file mode 100644 index 0000000000..b95ba5a92d --- /dev/null +++ b/src/MaaWpfGui/Helper/Utils.cs @@ -0,0 +1,66 @@ +// +// MaaWpfGui - A part of the MaaCoreArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// + +using System; + +namespace MaaWpfGui +{ + public static class Utils + { + /// + /// 获取yj历时间 + /// + /// yj历时间 + public static DateTime GetYJTimeNow() + { + return DateTime.UtcNow.AddHours(4); + } + + /// + /// 获取yj历时间字符串 + /// + /// yj历时间的字符串表示形式 + public static string GetYJTimeNowString() + { + return GetYJTimeNow().ToString(); + } + + /// + /// 获取yj历日期 + /// + /// yj历日期 + public static DateTime GetYJTimeDate() + { + return GetYJTimeNow().Date; + } + + /// + /// 获取yj历日期字符串 + /// + /// yj历日期的字符串表示形式 + public static string GetYJTimeDateString() + { + return GetYJTimeDate().ToString(); + } + + /// + /// 将日期转换为yj历日期 + /// + /// + /// yj历格式的时间 + public static DateTime ToYJTime(DateTime dt) + { + return dt.AddHours(4); + } + } +} diff --git a/src/MaaWpfGui/MaaWpfGui.csproj b/src/MaaWpfGui/MaaWpfGui.csproj index face25fa5e..1508a6ac98 100644 --- a/src/MaaWpfGui/MaaWpfGui.csproj +++ b/src/MaaWpfGui/MaaWpfGui.csproj @@ -103,6 +103,7 @@ MSBuild:Compile Designer + diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index aae571ac4d..95ffedab1b 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -500,7 +500,7 @@ namespace MaaWpfGui } else if (taskChain == "Mall") { - settingsModel.LastCreditFightTaskTime = DateTime.UtcNow.AddHours(4).Date.ToString(); + settingsModel.LastCreditFightTaskTime = Utils.GetYJTimeDateString(); } mainModel.AddLog(Localization.GetString("CompleteTask") + taskChain); diff --git a/src/MaaWpfGui/Main/SettingsViewModel.cs b/src/MaaWpfGui/Main/SettingsViewModel.cs index 31528878bc..6fefe2ac5b 100644 --- a/src/MaaWpfGui/Main/SettingsViewModel.cs +++ b/src/MaaWpfGui/Main/SettingsViewModel.cs @@ -1032,7 +1032,7 @@ namespace MaaWpfGui } /* 访问好友设置 */ - private string _lastCreditFightTaskTime = ViewStatusStorage.Get("Visit.LastCreditFightTaskTime", DateTime.UtcNow.AddHours(4).Date.AddDays(-1).ToString()); + private string _lastCreditFightTaskTime = ViewStatusStorage.Get("Visit.LastCreditFightTaskTime", Utils.GetYJTimeDate().AddDays(-1).ToString()); public string LastCreditFightTaskTime { @@ -1053,7 +1053,7 @@ namespace MaaWpfGui { get { - if (DateTime.UtcNow.AddHours(4).Date > DateTime.Parse(LastCreditFightTaskTime).Date) + if (Utils.GetYJTimeDate() > DateTime.Parse(LastCreditFightTaskTime).Date) { return _creditFightTaskEnabled; } diff --git a/src/MaaWpfGui/Main/TaskQueueViewModel.cs b/src/MaaWpfGui/Main/TaskQueueViewModel.cs index a3ff975969..09dc36416d 100644 --- a/src/MaaWpfGui/Main/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/Main/TaskQueueViewModel.cs @@ -309,26 +309,26 @@ namespace MaaWpfGui private bool NeedToUpdateDatePrompt() { - var now = DateTime.UtcNow.AddHours(8); + var now = Utils.GetYJTimeNow(); var hour = now.Hour; var min = now.Minute; - if (hour >= 0 && hour < 4) - { - now = now.AddDays(-1); - } - if (min == 0 && hour == 16) + // yj历的16点 + if (min == 0 && hour == 12) { return true; } - else if (_curDayOfWeek == now.DayOfWeek) - { - return false; - } else { - _curDayOfWeek = now.DayOfWeek; - return true; + if (_curDayOfWeek == now.DayOfWeek) + { + return false; + } + else + { + _curDayOfWeek = now.DayOfWeek; + return true; + } } }