mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
add basic timezone support for gachaitem
This commit is contained in:
@@ -27,6 +27,6 @@ internal class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
|
||||
/// <inheritdoc/>
|
||||
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString(Format, CultureInfo.CurrentCulture));
|
||||
writer.WriteStringValue(value.ToLocalTime().ToString(Format, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,8 @@
|
||||
VerticalAlignment="Center"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding HotKeyOptions.VirtualKeys}"
|
||||
SelectedItem="{Binding HotKeyOptions.MouseClickRepeatForeverKeyCombination.KeyNameValue, Mode=TwoWay}"/>
|
||||
SelectedItem="{Binding HotKeyOptions.MouseClickRepeatForeverKeyCombination.KeyNameValue, Mode=TwoWay}"
|
||||
Style="{StaticResource DefaultComboBoxStyle}"/>
|
||||
<ToggleSwitch
|
||||
MinWidth="120"
|
||||
VerticalAlignment="Center"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Web.Request.QueryString;
|
||||
using Windows.ApplicationModel.Store.Preview.InstallControl;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab;
|
||||
|
||||
@@ -54,6 +55,19 @@ internal readonly struct PlayerUid
|
||||
};
|
||||
}
|
||||
|
||||
public TimeZoneInfo GetTimeZoneInfo()
|
||||
{
|
||||
// 美服 UTC-05
|
||||
// 欧服 UTC+02
|
||||
// 其他 UTC+08
|
||||
return Region switch
|
||||
{
|
||||
"os_usa" => ServerTimeZoneInfo.UsaTimeZone,
|
||||
"os_euro" => ServerTimeZoneInfo.EuroTimeZone,
|
||||
_ => ServerTimeZoneInfo.CommonTimeZone,
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
17
src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/ServerTimeZoneInfo.cs
Normal file
17
src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/ServerTimeZoneInfo.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab;
|
||||
|
||||
internal static class ServerTimeZoneInfo
|
||||
{
|
||||
private static readonly TimeZoneInfo UsaTimeZoneValue = TimeZoneInfo.CreateCustomTimeZone("Server:UTC-05", new TimeSpan(-05, 0, 0), "UTC-05", "UTC-05");
|
||||
private static readonly TimeZoneInfo EuroTimeZoneValue = TimeZoneInfo.CreateCustomTimeZone("Server:UTC+02", new TimeSpan(+02, 0, 0), "UTC+02", "UTC+02");
|
||||
private static readonly TimeZoneInfo CommonTimeZoneValue = TimeZoneInfo.CreateCustomTimeZone("Server:UTC+08", new TimeSpan(+08, 0, 0), "UTC+08", "UTC+08");
|
||||
|
||||
public static TimeZoneInfo UsaTimeZone { get => UsaTimeZoneValue; }
|
||||
|
||||
public static TimeZoneInfo EuroTimeZone { get => EuroTimeZoneValue; }
|
||||
|
||||
public static TimeZoneInfo CommonTimeZone { get => CommonTimeZoneValue; }
|
||||
}
|
||||
Reference in New Issue
Block a user