public TimeSpan SynchronizeLocalClock() { TimeSpan diff = MeasureSystemClockError(); DateTime corrected = DateTime.Now + diff; NistClock.SetTimeLocal(corrected); return(diff); }
public TimeSpan MeasureSystemClockError() { TimeSpan roundTrip; string daytimeString = QueryDaytimeString(out roundTrip); double halfTripMilliseconds = roundTrip.TotalMilliseconds / 2.0; TimeSpan halfTrip = new TimeSpan(0, 0, 0, 0, (int)halfTripMilliseconds); DateTime nist = NistClock.ParseDaytimeProtocol(daytimeString) + halfTrip; DateTime here = DateTime.Now.ToUniversalTime(); TimeSpan diff = (nist - here); return(diff); }