| | |
| | | /// <summary>
|
| | | /// 当前服务器时间
|
| | | /// </summary>
|
| | | public static DateTime ServerNow {
|
| | | get {
|
| | | public static DateTime ServerNow
|
| | | {
|
| | | get
|
| | | {
|
| | | float tick = Time.realtimeSinceStartup - _checkTime;
|
| | | DateTime real = _serverTime.AddSeconds(tick);
|
| | | return real;
|
| | |
| | | /// <summary>
|
| | | /// 年份
|
| | | /// </summary>
|
| | | public static int Year {
|
| | | public static int Year
|
| | | {
|
| | | get { return ServerNow.Year; }
|
| | | }
|
| | | /// <summary>
|
| | | /// 月份
|
| | | /// </summary>
|
| | | public static int Month {
|
| | | public static int Month
|
| | | {
|
| | | get { return ServerNow.Month; }
|
| | | }
|
| | | /// <summary>
|
| | | /// 天
|
| | | /// </summary>
|
| | | public static int Day {
|
| | | public static int Day
|
| | | {
|
| | | get { return ServerNow.Day; }
|
| | | }
|
| | | /// <summary>
|
| | | /// 小时
|
| | | /// </summary>
|
| | | public static int Hour {
|
| | | public static int Hour
|
| | | {
|
| | | get { return ServerNow.Hour; }
|
| | | }
|
| | | /// <summary>
|
| | | /// 分钟
|
| | | /// </summary>
|
| | | public static int Minute {
|
| | | public static int Minute
|
| | | {
|
| | | get { return ServerNow.Minute; }
|
| | | }
|
| | | /// <summary>
|
| | | /// 秒
|
| | | /// </summary>
|
| | | public static int Second {
|
| | | public static int Second
|
| | | {
|
| | | get { return ServerNow.Second; }
|
| | | }
|
| | | /// <summary>
|
| | |
| | | /// <summary>
|
| | | /// 服务器时间相比起始时间的秒数(主要方便比较)
|
| | | /// </summary>
|
| | | public static int AllSeconds {
|
| | | get {
|
| | | public static int AllSeconds
|
| | | {
|
| | | get
|
| | | {
|
| | | TimeSpan t = ServerNow - OriginalTime;
|
| | | return t.Seconds;
|
| | | }
|
| | | }
|
| | |
|
| | | public static int OpenDay {
|
| | | public static int OpenDay
|
| | | {
|
| | | get; private set;
|
| | | }
|
| | |
|
| | | public static bool IsMixServer {
|
| | | public static bool IsMixServer
|
| | | {
|
| | | get; private set;
|
| | | }
|
| | |
|
| | | public static int MixOpenDay {
|
| | | public static int MixOpenDay
|
| | | {
|
| | | get; private set;
|
| | | }
|
| | |
|
| | | public static DateTime openServerTime;
|
| | |
|
| | | public static int OpenWeekCnt
|
| | | {
|
| | |
| | | {
|
| | | DateTime n = new DateTime(vNetData.Year, vNetData.Month, vNetData.Day, vNetData.Hour, vNetData.Minute, vNetData.Second);
|
| | | _serverTime = n;
|
| | | DebugEx.Log("OnRefreshServerTime月份:"+_serverTime.Month);
|
| | | DebugEx.Log("OnRefreshServerTime月份:" + _serverTime.Month);
|
| | | _checkTime = Time.realtimeSinceStartup;
|
| | | if (OnServerTimeRefresh != null) OnServerTimeRefresh();
|
| | | TimeDownMgr.Instance.Begin(TimeDownMgr.CoolTimeType.SyncServerTime, 60, (float tick) => {
|
| | | TimeDownMgr.Instance.Begin(TimeDownMgr.CoolTimeType.SyncServerTime, 60, (float tick) =>
|
| | | {
|
| | | SyncServerTime();
|
| | | }, 60);
|
| | | }
|
| | |
| | | OpenDay = package.Day;
|
| | | IsMixServer = package.IsMixServer == 1;
|
| | | MixOpenDay = package.MixDay;
|
| | | if (OnServerOpenDayRefresh != null) {
|
| | | DateTime.TryParse(package.OpenServerTime, out openServerTime);
|
| | | if (OnServerOpenDayRefresh != null)
|
| | | {
|
| | | OnServerOpenDayRefresh();
|
| | | }
|
| | | }
|