Fix timezone #19

This commit is contained in:
cxfksword
2023-04-16 21:12:45 +08:00
parent 56f710c467
commit bcac10dd2f

View File

@@ -8,10 +8,12 @@ namespace Jellyfin.Plugin.Danmu.Core
{
public static class Utils
{
private static TimeZoneInfo beijingTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
// 北京时区
static TimeZoneInfo beijingTimeZone = TimeZoneInfo.CreateCustomTimeZone("GMT+8", TimeSpan.FromHours(8), null, null);
public static DateTime UnixTimeStampToDateTime(long unixTimeStamp)
{
// 转成北京时间bilibili接口的年份只要是根据北京时间返回
// Unix timestamp is seconds past epoch
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dateTime = TimeZoneInfo.ConvertTime(dateTime.AddSeconds(unixTimeStamp), TimeZoneInfo.Utc, beijingTimeZone);