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

Alistair Bush alistair.bush at gmail.com
Mon Oct 28 06:35:26 UTC 2013

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.

Jump to [1] if you want to see what my system looks like.

I have been able to track down the issue I believe to somewhere either
in ical.c ( ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData to
be exact) or CurrentSystemTimeZone. Or potentially a combo of both?

icall GetTimeZoneData seems to be returning its data in the incorrect
order.  I have attempted to confirm for a <+13GMT southern hemisphere
timezone (TZ="Australia/Sydney") but the results seem to suggest that
using TZ isn't supported.  I am therefore unable to determine whether
this is for +13GMT specifically or for some other reason.

Basically I have writing the following unit test to confirm the data
coming from ical_...GetTimeZoneData.

        delegate bool GetTimeZoneDataInternal (int year, out Int64[]
data, out string[] names);

        GetTimeZoneDataInternal getTimeZoneData;

        public void GetTimeZoneData() {
            TimeZone t = TimeZone.CurrentTimeZone;

            getTimeZoneData =
                t.GetType ().GetMethod ("GetTimeZoneData",
BindingFlags.NonPublic | BindingFlags.Static |

            long[] data = null;
            string[] names = null;

            var result = getTimeZoneData (2013, out data, out names);

            Assert.IsTrue (result);

The names variable contains [ "NZDT", "NZST"  ] while data contains [
635009004000000000, 635160168000000000, 468000000000, -36000000000 ].
 This is interesting as per the documentation of this method "data[3]:
 additional offset when daylight saving (in TimeSpan ticks).".
According to this function, in NZ we jump backwards into daylight

Sadly my experience with timezone calculations is limited, my C is
poor and with a weath of knowledge out here it is far to easy to ask.

Does anyone have a clue what is going on here?

Any help would be appreciated.


$ cat /etc/gentoo-release
Gentoo Base System release 2.2
$ date +%Z
$ mono --version
Mono Runtime Engine version 3.2.3 (branch-master/a57f9ce Sun Oct 20
00:18:37 NZDT 2013)
Copyright (C) 2002-2013 Novell, Inc, Xamarin Inc and Contributors.
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

More information about the Mono-devel-list mailing list