chore: 调整格式化字符串

This commit is contained in:
uye
2024-09-05 20:23:39 +08:00
parent 7e32a8ce40
commit c17593e913
2 changed files with 5 additions and 4 deletions

View File

@@ -52,6 +52,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ehem/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=esource/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Favourite/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=filetime/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=findstr/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLASHW/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FLASHWINFO/@EntryIndexedValue">True</s:Boolean>

View File

@@ -11,6 +11,7 @@
// but WITHOUT ANY WARRANTY
// </copyright>
#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<string, int> _clientTypeTimezone = new Dictionary<string, int>
private static readonly Dictionary<string, int> _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)