Exemple #1
0
        /// <summary>
        /// Parse a NTP time in the short format
        /// </summary>
        /// <param name="PackedNtpTime">NTP time in short format</param>
        /// <returns>Unpacked NTP Time</returns>
        public static NtpShortTimeInterval ParseNtpShortInterval(uint PackedNtpTime)
        {
            NtpShortTimeInterval ntpTime = new NtpShortTimeInterval();

            ntpTime.Fraction = (ushort)(PackedNtpTime & 0xFFFF);
            ntpTime.Seconds  = (ushort)(PackedNtpTime >> 16);
            return(ntpTime);
        }
Exemple #2
0
        /// <summary>
        /// Convert a ShortTime structure to file time
        /// </summary>
        /// <param name="NtpTime">The short ntp time to convert</param>
        /// <returns>Corresponding filetime duration</returns>
        public static ulong NtpShortIntervalToFileTime(NtpShortTimeInterval NtpTime)
        {
            BigInteger fileTime = NtpTime.Fraction;

            fileTime *= OneHundredNsInOneSecond;
            fileTime /= MaxUshortPlusOne;
            fileTime += NtpTime.Seconds * OneHundredNsInOneSecond;
            return((ulong)(fileTime));
        }