50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
|
|
using cfg.ActorCfg;
|
|||
|
|
using cfg.CharacterCfg;
|
|||
|
|
using Framework;
|
|||
|
|
using Gameplay.Net;
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace Gameplay
|
|||
|
|
{
|
|||
|
|
public partial class CommonUtils
|
|||
|
|
{
|
|||
|
|
public enum E_TimeType
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 本地
|
|||
|
|
/// </summary>
|
|||
|
|
Local,
|
|||
|
|
/// <summary>
|
|||
|
|
/// 服务器
|
|||
|
|
/// </summary>
|
|||
|
|
Server,
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static readonly DateTime Epoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取当前时间
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="timeType"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public static DateTime GetCurTime(E_TimeType timeType)
|
|||
|
|
{
|
|||
|
|
return timeType switch
|
|||
|
|
{
|
|||
|
|
E_TimeType.Local => DateTime.Now,
|
|||
|
|
E_TimeType.Server => Epoch.AddMilliseconds(NetManager.Instance.ServerTimeMS).ToLocalTime(),
|
|||
|
|
_ => DateTime.MinValue,
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 判断时间是否是上午
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dateTime"></param>
|
|||
|
|
/// <returns>true:上午,false:下午</returns>
|
|||
|
|
public static bool IsAM(DateTime dateTime)
|
|||
|
|
{
|
|||
|
|
return dateTime.Hour < 12;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|