0
votes

I try to calculate the ramadan feast. I use the HijriCalendar for this issue. I have check wikipedia and ramadan feast is on the end of the islamic month Ramadan.

Some dates are good but other on the wrong day (1 day deferred)

var hijriCalendar = new HijriCalendar();

for (var i = 1431; i <= 1438; i++)
{
    var dateTime = new DateTime(i, 10, 1, hijriCalendar);
    Console.WriteLine(dateTime.ToString("yyyy-MM-dd"));
}

Public Holiday Ramadan Feast First value calculated, second the correct value

  • 2010-09-09 (2010-09-09)
  • 2011-08-30 (2011-08-30)
  • 2012-08-18 (2012-08-19) WRONG +1
  • 2013-08-07 (2013-08-08) WRONG +1
  • 2014-07-28 (2014-07-28)
  • 2015-07-17 (2015-07-17)
  • 2016-07-06 (2016-07-05) WRONG -1
  • 2017-06-25 (2017-07-25)

Source of correct date https://www.timeanddate.com/holidays/turkey/ramadan-feast

1

1 Answers

0
votes

It looks like the C# HijriCalendar acknowledges that the dates of Ramadan can be off and offers a HijriCalendar.HijriAdjustment Property to account for variances from year to year.

This implementation of the HijriCalendar class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions

Check out this page for more information about it.

https://msdn.microsoft.com/en-us/library/system.globalization.hijricalendar.hijriadjustment(v=vs.110).aspx