Hi,
For Turkey public holidays, Ramadan holidays and FeastOfSacrifices holidays calculations are not completely correct for some years. In one Gregorian year, 2000 or 2033 for example, two Ramadan holidays may exist (in January and in December.) To cover that case GetHijriYear() method and Ramadan and FeastOfSacrifices holidays methods should return multiple results. Below is my solution:
private IEnumerable<int> GetHijriYears(int year)
{
var diff = year - 621;
var hijriYear = Convert.ToInt32(Math.Round(diff + decimal.Divide(diff, 33), MidpointRounding.ToZero));
return [hijriYear, hijriYear + 1];
}
public IEnumerable<DateTime> RamadanFirstDay(int year)
{
var hijriCalendar = new UmAlQuraCalendar();
var hijriYears = GetHijriYears(year);
foreach (var hijriYear in hijriYears)
{
var dateTime = hijriCalendar.ToDateTime(hijriYear, 10, 1, 0, 0, 0, 0);
if (dateTime.Year != year)
{
continue;
}
yield return dateTime;
}
}
Hi, For Turkey public holidays, Ramadan holidays and FeastOfSacrifices holidays calculations are not completely correct for some years. In one Gregorian year, 2000 or 2033 for example, two Ramadan holidays may exist (in January and in December.) To cover that case
GetHijriYear()
method andRamadan
andFeastOfSacrifices
holidays methods should return multiple results. Below is my solution: