Exemplo n.º 1
0
    public static void Main()
    {
        UmAlQuraCalendar cal    = new UmAlQuraCalendar();
        List <string>    months = new List <string>();
        string           output = String.Empty;

        // Get the current year in the UmAlQura calendar.
        int startYear = cal.GetYear(DateTime.Now);

        // Display the number of days in each month for the next five years.
        Console.WriteLine("          Days in Each Month, {0} to {1}\n",
                          startYear, startYear + 4);

        Console.WriteLine("Month     {0}     {1}     {2}     {3}     {4}",
                          startYear, startYear + 1, startYear + 2, startYear + 3,
                          startYear + 4);
        for (int year = startYear; year <= startYear + 4; year++)
        {
            int days;
            for (int month = 1; month <= cal.GetMonthsInYear(year, UmAlQuraCalendar.UmAlQuraEra);
                 month++)
            {
                days = cal.GetDaysInMonth(year, month,
                                          UmAlQuraCalendar.UmAlQuraEra);
                output = String.Format("{0}     ", days);
                if (months.Count < month)
                {
                    months.Add(String.Format("{0,4}        {1}",
                                             month, output));
                }
                else
                {
                    months[month - 1] += "  " + output;
                }
            }
        }

        foreach (var item in months)
        {
            Console.WriteLine(item);
        }
    }