/// <summary>
        /// Subtracts the specified time difference from this instance.
        /// </summary>
        /// <param name="value">A time difference to subtract.</param>
        /// <returns>A time difference plus a time difference.</returns>
        public NtpTimestampDifference Subtract(NtpTimestampDifference value)
        {
            NtpTimestampDifference diff;

            try {
                diff = new NtpTimestampDifference(_difference - value._difference);
            }
            catch (OverflowException) {
                throw new OverflowException(string.Format("Cannot subtract {1} from {0}.", this, value));
            }
            return(diff);
        }
        /// <summary>
        /// Adds the specified time difference to this instance.
        /// </summary>
        /// <param name="value">A time difference to add.</param>
        /// <returns>A time difference plus a time difference.</returns>
        public NtpTimestampDifference Add(NtpTimestampDifference value)
        {
            NtpTimestampDifference difference;

            try {
                difference = new NtpTimestampDifference(_difference + value._difference);
            }
            catch (OverflowException) {
                throw new OverflowException(string.Format("Cannot add {1} to {0}.", this, value));
            }
            return(difference);
        }
예제 #3
0
        /// <summary>
        /// Subtracts the specified time difference from this instance.
        /// </summary>
        /// <param name="value">A time difference.</param>
        /// <returns>A timestamp plus a time difference.</returns>
        public NtpTimestamp Subtract(NtpTimestampDifference value)
        {
            bool flag;
            var  t = _timestamp - ((ulong)value.ToInt64());

            if (value.Positive)
            {
                flag = t > _timestamp;
            }
            else
            {
                flag = t < _timestamp;
            }
            if (flag)
            {
                throw new OverflowException(string.Format("Cannot subtract {1} from {0}.", this, value));
            }
            return(new NtpTimestamp(t));
        }