Rev. | 86e26ecde9d36b0074e6fb8a2a2b26250bb81d51 |
---|---|
大小 | 764 字节 |
时间 | 2022-11-30 01:06:13 |
作者 | yoshy |
Log Message | [MOD] UserDialogProxy の名前空間を UI 配下から UI.Dialog 配下に移動
|
using System;
namespace CleanAuLait48.Core.Time
{
public static class DateTimeHelper
{
private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private static readonly TimeZoneInfo TZ_JST = TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time");
public static DateTime JstNow => TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TZ_JST);
#if NET7_0
public static long ToUnixTime(DateTime time) => (long)((time - UNIX_EPOCH).TotalSeconds) * 1000000 + time.Microsecond;
#else
public static long ToUnixTime(DateTime time)
{
return (long) ((time - UNIX_EPOCH).TotalSeconds) * 1000000 + long.Parse(time.ToString("ffffff"));
}
#endif
}
}