NewGaoKaoApi/New_College.Common/Helper/TimeUtil.cs

24 lines
576 B
C#

using System;
using NodaTime;
namespace YIJIYI.Core.Common.Helper
{
public class TimeUtil
{
public static DateTime GetCstDateTime()
{
Instant now = SystemClock.Instance.GetCurrentInstant();
var shanghaiZone = DateTimeZoneProviders.Tzdb["Asia/Shanghai"];
return now.InZone(shanghaiZone).ToDateTimeUnspecified();
}
}
public static class DateTimeExtentions
{
public static DateTime ToCstTime(this DateTime time)
{
return TimeUtil.GetCstDateTime();
}
}
}