[Mono-dev] why does DateTime.Now.IsDaylightSavingTime() returns false when it should be true.

Robert Jordan robertj at gmx.net
Mon Oct 28 14:03:03 UTC 2013


On 28.10.2013 07:35, Alistair Bush wrote:
> I am trying to figure out why exactly running
> DateTime.Now.IsDaylightSavingTIme() returns false.
> I live in the Auckland/Pacific timezone and pretty much everywhere I
> look it confirms that yes it is daylight saving time.

Unfortunately, I don't remember the details, but I'm pretty
sure that ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData
has a bug w/ respect to the Southern Hemisphere.

The code assumes that a year always begins outside a DST zone,
and this is obviously incorrect for the Southern Hemisphere.

To fix this, the local var "is_daylight" must be properly
initialized. Currently, it's always 0 at start, but it must
be initialized with 1 when January, 1st is inside a DST
zone.

Maybe this:

	is_daylight = start.tm_isdst > 0;

just before

         /* For each day of the year, calculate the tm_gmtoff. */
         for (day = 0; day < 365; day++) {

Robert




More information about the Mono-devel-list mailing list