using System;

namespace SGModule.Net {
    // 服务器时钟管理类
    public static class ServerClock {
        private static long _timeDifference; // 本地与服务器的时间偏差

        public static void Init(long serverTime) {
            _timeDifference = serverTime - Now();
        }

        public static long GetCurrentServerTime() {
            return Now() + _timeDifference;
        }

        private static long Now() {
            return DateTimeOffset.UtcNow.ToUnixTimeSeconds();
        }
    }
}
