[Mono-dev] DateTime.Now

Neale Ferguson neale at sinenomine.net
Thu Jun 16 19:42:27 UTC 2016


When DateTime.Now looks to adjust its value based on timezone (and
daylight saving requirements), it fetches a value UtcNow. This value is
obtained by a call to unmanaged code GetSystemTimeAsFileTime() which the
JIT maps to mono_100ns_datetime(). This routine uses gettimeofday() to
fetch the current time. However, this is the local time and it does not
adjust it to be UTC. So the comparison it makes in the test to see if the
datetime has transitioned to or from daylight saving or not is done
against local time and not UTC.


I have instrumented the code to show how the test against the rule appears
to be being made against local time and not UTC at
http://pastebin.ca/3629144.

Neale



More information about the Mono-devel-list mailing list