From c17593e91320c092e8e37d2f52a976dca2abdb58 Mon Sep 17 00:00:00 2001
From: uye <99072975+ABA2396@users.noreply.github.com>
Date: Thu, 5 Sep 2024 20:23:39 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E6=A0=BC=E5=BC=8F?=
=?UTF-8?q?=E5=8C=96=E5=AD=97=E7=AC=A6=E4=B8=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MAA.sln.DotSettings | 1 +
src/MaaWpfGui/Extensions/DateTimeExtension.cs | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/MAA.sln.DotSettings b/MAA.sln.DotSettings
index 3e53fc188c..57ad328c91 100644
--- a/MAA.sln.DotSettings
+++ b/MAA.sln.DotSettings
@@ -52,6 +52,7 @@
True
True
True
+ True
True
True
True
diff --git a/src/MaaWpfGui/Extensions/DateTimeExtension.cs b/src/MaaWpfGui/Extensions/DateTimeExtension.cs
index e7aae1728c..4e6497c44f 100644
--- a/src/MaaWpfGui/Extensions/DateTimeExtension.cs
+++ b/src/MaaWpfGui/Extensions/DateTimeExtension.cs
@@ -11,6 +11,7 @@
// but WITHOUT ANY WARRANTY
//
+#nullable enable
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -25,7 +26,7 @@ namespace MaaWpfGui.Extensions
private static string ClientType => ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, string.Empty);
- private static readonly Dictionary _clientTypeTimezone = new Dictionary
+ private static readonly Dictionary _clientTypeTimezone = new()
{
{ string.Empty, 8 },
{ "Official", 8 },
@@ -56,10 +57,9 @@ namespace MaaWpfGui.Extensions
return dt is { Month: 4, Day: 1 };
}
- public static string ToLocalTimeString(this DateTime dt)
+ public static string ToLocalTimeString(this DateTime dt, string? format = null, string? shortDatePattern = null, string? longTimePattern = "HH:mm:ss")
{
- var dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
- return dt.ToLocalTime().ToString(dateTimeFormat.ShortDatePattern + " HH:mm:ss");
+ return dt.ToLocalTime().ToString(format ?? $"{shortDatePattern ?? CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern} {longTimePattern}", CultureInfo.CurrentCulture);
}
public static DateTime ToDateTime(this System.Runtime.InteropServices.ComTypes.FILETIME filetime)