add basic timezone support for gachaitem

This commit is contained in:
Lightczx
2023-11-09 17:18:56 +08:00
parent 71363f4d8d
commit 3005031b39
4 changed files with 34 additions and 2 deletions

View File

@@ -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));
}
}

View File

@@ -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"

View File

@@ -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()
{

View 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; }
}