Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        static void DemoCalendar()
        {
            DateTime today = DateTime.Now;

            Console.Clear();            // clear console

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("# Demo: liturgical calendar flags\n");
            Console.ResetColor();
            Console.WriteLine(" Liturgical year:\t" + today + "\n");

            // Populate struct calendar
            LiturgicalCalendar.PopulateLiturgicalFlags(today);

            // Display Calendar struct

            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.ApostleStAndrew, "Feast of St. Andrew the Apostle");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.AdventSunday, "First Sunday of Advent");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.ImmaculateConception, "Feast of the Immaculate Conception of Mary The Mother of God");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.ChristmasDay, "Christmas Day");
            //DemoColorizeFeast( LiturgicalCalendar.LiturgicalFlags.Dec31, "Dec31" );
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.SolemnityOfMary, "\tSolemnity Of Mary");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.Epiphany, "\tEpiphany");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.EpiphanySunday, "\tEpiphany Sunday");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.Baptism, "\tBaptism");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.StartFirstOrdinaryTime, "\tStart of 1st Ordinary Time");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.AshWednesday, "Ash Wednesday");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.Easter, "\tEaster");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.Ascension, "\tAscension");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.AscensionSunday, "\tAscension Sunday");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.Pentecost, "\tPentecost");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.PentecostSunday, "\tPentecost Sunday");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.StartSecondOrdinaryTime, "\tStart of 2nd Ordinary Time");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.AllSaints, "All Saints Day");
            DemoColorizeFeast(LiturgicalCalendar.LiturgicalFlags.AllSouls, "All Souls Day");

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("\n# Liturgical Seasons:\n");
            Console.ResetColor();

            //Console.BackgroundColor = ConsoleColor.Black;

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(" Advent Season:\t\t");
            Console.ResetColor();
            if (LiturgicalCalendar.LiturgicalFlags.IsAdvent)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            Console.WriteLine(LiturgicalCalendar.LiturgicalFlags.IsAdvent);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Christmas Season:\t");
            Console.ResetColor();
            if (LiturgicalCalendar.LiturgicalFlags.IsChristmas)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            Console.WriteLine(LiturgicalCalendar.LiturgicalFlags.IsChristmas);

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(" Lent Season:\t\t");
            Console.ResetColor();
            if (LiturgicalCalendar.LiturgicalFlags.IsLent)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            Console.WriteLine(LiturgicalCalendar.LiturgicalFlags.IsLent);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(" Easter Season:\t\t");
            Console.ResetColor();
            if (LiturgicalCalendar.LiturgicalFlags.IsEaster)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            Console.WriteLine(LiturgicalCalendar.LiturgicalFlags.IsEaster);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(" Ordinary Time:\t\t");
            Console.ResetColor();
            if (LiturgicalCalendar.LiturgicalFlags.IsOrdinary)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
            }
            Console.WriteLine(LiturgicalCalendar.LiturgicalFlags.IsOrdinary);

            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("\nPress any key to continue.");
            Console.ResetColor();
            Console.ReadKey();
        }