refactor: 优化鱼人节判断方法

This commit is contained in:
MistEO
2023-04-01 13:22:19 +08:00
parent 7e7e3c67ba
commit b8bb725ed4
3 changed files with 8 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
// <copyright file="DateTimeExtension.cs" company="MaaAssistantArknights">
// <copyright file="DateTimeExtension.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
@@ -50,5 +50,10 @@ namespace MaaWpfGui.Extensions
{
return dt.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
}
public static bool IsAprilFoolsDay(this DateTime dt)
{
return dt.Month == 4 && dt.Day == 1;
}
}
}

View File

@@ -2633,19 +2633,13 @@ namespace MaaWpfGui.ViewModels.UI
}
}
public static bool AprilFoolsDay()
{
var yjDate = DateTime.UtcNow.ToYJDate();
return yjDate.Month == 4 && yjDate.Day == 1;
}
/// <summary>
/// Did you buy wine?
/// </summary>
/// <returns>The answer.</returns>
public bool DidYouBuyWine()
{
if (AprilFoolsDay())
if (DateTime.UtcNow.ToYJDate().IsAprilFoolsDay())
{
return true;
}

View File

@@ -306,7 +306,7 @@ namespace MaaWpfGui.ViewModels.UI
UpdateStageList(true);
RefreshCustonInfrastPlan();
if (SettingsViewModel.AprilFoolsDay())
if (DateTime.UtcNow.ToYJDate().IsAprilFoolsDay())
{
AddLog(LocalizationHelper.GetString("BuyWineOnAprilFoolsDay"), UiLogColor.Info);
}