System.Globalization.GregorianCalendar.GetMonthsInYear C# (CSharp) Method

GetMonthsInYear() public method

public GetMonthsInYear ( int year, int era ) : int
year int
era int
return int
        public override int GetMonthsInYear(int year, int era)
        {
            if (era == CurrentEra || era == ADEra) {
                if (year >= 1 && year <= MaxYear)
                {
                    return (12);
                }
                throw new ArgumentOutOfRangeException(
                            "year",
                            String.Format(
                                CultureInfo.CurrentCulture,
                                Environment.GetResourceString("ArgumentOutOfRange_Range"),
                                1,
                                MaxYear));
            }
            throw new ArgumentOutOfRangeException("era", Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue"));
        }

Usage Example

Beispiel #1
0
        public WorkYear(int year, WorkDayParserSettings parserSettings, int hitListLookBackInWeeks, float hoursPerDay, PNSearchViewModel pnSearch, PositionSearchViewModel positionSearch)
        {
            this.hitListLookBackInWeeks = hitListLookBackInWeeks;
            this.pnSearch = pnSearch;
            this.positionSearch = positionSearch;
            this.Year = year;
            this.Months = new ObservableCollection<WorkMonth>();
            this.Weeks = new ObservableCollection<WorkWeek>();

            var germanSpecialDays = SpecialDaysUtils.GetGermanSpecialDays(year);

            var cal = new GregorianCalendar();
            for (int month = 1; month <= cal.GetMonthsInYear(year); month++)
            {
                WorkMonth wm = new WorkMonth(year, month, germanSpecialDays, parserSettings, hoursPerDay);
                this.Months.Add(wm);
                foreach (var workWeek in wm.Weeks)
                {
                    this.Weeks.Add(workWeek);
                    workWeek.PropertyChanged += this.workWeek_PropertyChanged;
                }
            }
            this.ProjectHitlist = new QuickFillObservableCollection<HitlistInfo>();
            this.PositionHitlist = new QuickFillObservableCollection<HitlistInfo>();
            this.UpdateProjectHitlistAsync();
            this.UpdatePositionHitlistAsync();
        }
All Usage Examples Of System.Globalization.GregorianCalendar::GetMonthsInYear