Cheesebaron.MvxPlugins.SimpleWebToken.SimpleWebToken.GetTimeAsDateTime C# (CSharp) Method

GetTimeAsDateTime() private static method

Convert the time in seconds to a DateTime object based on the base time defined by the Simple Web Token.
private static GetTimeAsDateTime ( string expiryTime ) : System.DateTime
expiryTime string The time in seconds.
return System.DateTime
        private static DateTime GetTimeAsDateTime(string expiryTime)
        {
            long totalSeconds;
            if (!long.TryParse(expiryTime, out totalSeconds))
            {
                throw new ArgumentOutOfRangeException(nameof(expiryTime), "Invalid expiry time. Expected the time to be in seconds passed from 1 January 1970.");
            }

            var maxSeconds = (long)(DateTime.MaxValue - _swtBaseTime).TotalSeconds - 1;
            if (totalSeconds > maxSeconds)
            {
                totalSeconds = maxSeconds;
            }

            return ToDateTimeFromEpoch(totalSeconds);
        }
    }