public bool IsIsraeliDaylightSavingsTime(CalendarDate date, CalendarEngine engine) { // Get Jewish year of Yom Kippur in the passed Gregorian year int a = engine.absoluteFromGregorianDate(new CalendarDate(31, 12, date.Year)); CalendarDate jewishCurrent = engine.jewishDateFromAbsolute(a); // Get Last Friday before 2nd of April int dstBegin = engine.absoluteFromGregorianDate(new CalendarDate(2, 4, date.Year)); // 2 April dstBegin--; // get the day before 2nd of April while (engine.GetWeekday(dstBegin) != 5) // gets the weekday, 5 = Friday { dstBegin--; // counts to the previous day until Friday } // Get Sunday between Rosh Hashana and Yom Kippur // Take the first Sunday on or after 3rd of Tishri int dstEnd = engine.absoluteFromJewishDate(new CalendarDate(3, 7, jewishCurrent.Year)); while (engine.GetWeekday(dstEnd) != 0) // gets the weekday, 0 = Sunday { dstEnd++; // counts to the next day until Sunday } // Check if the current date is between the start and end date ... int currentDate = engine.absoluteFromGregorianDate(date); if (currentDate >= dstBegin && currentDate < dstEnd) { return(true); } else { return(false); } }
public int GetWeekdayOfHebrewDate(int hebDay, int hebMonth, int hebYear, CalendarEngine engine) { int absDate = engine.absoluteFromJewishDate(new CalendarDate(hebDay, hebMonth, hebYear)); return(absDate % 7); }