I had a problem getting the components of the day, month and year of a C # DateTime object using the Um al Qura calendar.
Code snippet:
DateTime date = new DateTime(2013, 6, 24); UmAlQuraCalendar umAlQuraCalendar = new UmAlQuraCalendar(); int year = umAlQuraCalendar.GetYear(date); int month = umAlQuraCalendar.GetMonth(date); int day = umAlQuraCalendar.GetDayOfMonth(date);
After the launch of this year there will be 1434, and the month will be 8, which is correct. However, day 14, which is incorrect (according to here: http://www.al-habib.info/islamic-calendar/islamic-calendar-ummulqura-2013.htm )
If I changed the code to:
DateTime date = new DateTime(2013, 6, 24, 0, 0, 0, 1); // ie One millisecond after midnight UmAlQuraCalendar umAlQuraCalendar = new UmAlQuraCalendar(); int year = umAlQuraCalendar.GetYear(date); int month = umAlQuraCalendar.GetMonth(date); int day = umAlQuraCalendar.GetDayOfMonth(date);
Then the day is 15, which is true.
To make the situation more complicated, this code is at the back of a large application: C # code is called from exe VB6.
If I extract the first fragment above into a standalone C # project (.NET 2.0), then the day will be 15, which is true.
I checked everything I could think that might differ between the two projects: the .NET version, the target platform platform (x86), but cannot see anything obvious.
Any thoughts were greatly appreciated.