public static void PopulateLiturgicalFlags(DateTime inputDate) { LiturgicalCalendar.LiturgicalFlags.year = inputDate.Year; // previous year LiturgicalCalendar.LiturgicalFlags.ApostleStAndrew = new DateTime(LiturgicalCalendar.LiturgicalFlags.year - 1, 11, 30); LiturgicalCalendar.LiturgicalFlags.AdventSunday = CalendarCalculations.NearestSunday(LiturgicalCalendar.LiturgicalFlags.ApostleStAndrew); LiturgicalCalendar.LiturgicalFlags.ImmaculateConception = new DateTime(LiturgicalCalendar.LiturgicalFlags.year - 1, 12, 6); LiturgicalCalendar.LiturgicalFlags.ChristmasDay = new DateTime(LiturgicalCalendar.LiturgicalFlags.year - 1, 12, 25); LiturgicalCalendar.LiturgicalFlags.Dec31 = new DateTime(LiturgicalCalendar.LiturgicalFlags.year - 1, 12, 31); // this year LiturgicalCalendar.LiturgicalFlags.SolemnityOfMary = new DateTime(LiturgicalCalendar.LiturgicalFlags.year, 1, 1); LiturgicalCalendar.LiturgicalFlags.Epiphany = LiturgicalCalendar.LiturgicalFlags.ChristmasDay.AddDays(12); LiturgicalCalendar.LiturgicalFlags.EpiphanySunday = CalendarCalculations.NearestSunday(LiturgicalCalendar.LiturgicalFlags.Epiphany); LiturgicalCalendar.LiturgicalFlags.Baptism = LiturgicalCalendar.LiturgicalFlags.EpiphanySunday.AddDays(7); LiturgicalCalendar.LiturgicalFlags.StartFirstOrdinaryTime = LiturgicalCalendar.LiturgicalFlags.Baptism.AddDays(1); LiturgicalCalendar.LiturgicalFlags.Easter = LiturgicalCalendar.Easter(LiturgicalCalendar.LiturgicalFlags.year); LiturgicalCalendar.LiturgicalFlags.AshWednesday = LiturgicalCalendar.LiturgicalFlags.Easter.AddDays(-46); LiturgicalCalendar.LiturgicalFlags.Ascension = LiturgicalCalendar.LiturgicalFlags.Easter.AddDays(39); LiturgicalCalendar.LiturgicalFlags.AscensionSunday = CalendarCalculations.NearestSunday(LiturgicalCalendar.LiturgicalFlags.Ascension); LiturgicalCalendar.LiturgicalFlags.Pentecost = LiturgicalCalendar.LiturgicalFlags.Easter.AddDays(49); LiturgicalCalendar.LiturgicalFlags.PentecostSunday = CalendarCalculations.NearestSunday(LiturgicalCalendar.LiturgicalFlags.Pentecost); LiturgicalCalendar.LiturgicalFlags.StartSecondOrdinaryTime = LiturgicalCalendar.LiturgicalFlags.Easter.AddDays(50); LiturgicalCalendar.LiturgicalFlags.AllSaints = new DateTime(LiturgicalCalendar.LiturgicalFlags.year, 11, 1); LiturgicalCalendar.LiturgicalFlags.AllSouls = new DateTime(LiturgicalCalendar.LiturgicalFlags.year, 11, 2); LiturgicalCalendar.LiturgicalFlags.IsAdvent = IsAdvent(inputDate); LiturgicalCalendar.LiturgicalFlags.IsChristmas = IsChristmas(inputDate); LiturgicalCalendar.LiturgicalFlags.IsLent = IsLent(inputDate); LiturgicalCalendar.LiturgicalFlags.IsEaster = IsEaster(inputDate); LiturgicalCalendar.LiturgicalFlags.IsOrdinary = IsOrdinary(inputDate); }
public static bool IsOrdinary(DateTime today) { DateTime startDate1 = LiturgicalCalendar.LiturgicalFlags.StartFirstOrdinaryTime; DateTime endDate1 = LiturgicalCalendar.LiturgicalFlags.AshWednesday; DateTime startDate2 = LiturgicalCalendar.LiturgicalFlags.StartSecondOrdinaryTime; DateTime endDate2 = CalendarCalculations.NearestSunday(new DateTime(LiturgicalCalendar.LiturgicalFlags.year, 11, 30)); // ApostleStAndrew this year bool isOrdinary1 = CalendarCalculations.IsWithinDates(today, startDate1, endDate1); bool isOrdinary2 = CalendarCalculations.IsWithinDates(today, startDate2, endDate2); bool isOrdinary = (isOrdinary1 || isOrdinary2); return(isOrdinary); }