Files
jellyfin-plugin-danmu/Jellyfin.Plugin.Danmu/Core/Utils.cs
2023-04-16 21:12:45 +08:00

24 lines
827 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jellyfin.Plugin.Danmu.Core
{
public static class Utils
{
// 北京时区
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);
return dateTime;
}
}
}