Comparing local-time System.DateTime instances with each other is problematic if the UTC offset jumps forward between the two samples, e.g. due to summer time (CET/UTC+1 becomes CEST/UTC+2).
var before = new DateTime(2016, 3, 27, 1, 59, 0, DateTimeKind.Local);
var after = new DateTime(2016, 3, 27, 3, 0, 0, DateTimeKind.Local);
Console.WriteLine(after - before) // 01:01:00
While switching to UTC DateTimes is a possible solution, comparing System.DateTimes in general is problematic if the system date/time is adjusted between the two samples.
Stopwatch uses a monotonic time source which should be unaffected by either. In this PR, IrcConnection is modified to use it for ping timeout tracking.
Comparing local-time
System.DateTime
instances with each other is problematic if the UTC offset jumps forward between the two samples, e.g. due to summer time (CET/UTC+1 becomes CEST/UTC+2).While switching to UTC
DateTime
s is a possible solution, comparingSystem.DateTime
s in general is problematic if the system date/time is adjusted between the two samples.Stopwatch
uses a monotonic time source which should be unaffected by either. In this PR,IrcConnection
is modified to use it for ping timeout tracking.