System.Globalization.Calendar.GetDaysInMonth C# (CSharp) Метод

GetDaysInMonth() публичный Метод

public GetDaysInMonth ( int year, int month ) : int
year int
month int
Результат int
        public virtual int GetDaysInMonth(int year, int month)
        {
            return (GetDaysInMonth(year, month, CurrentEra));
        }

Same methods

Calendar::GetDaysInMonth ( int year, int month, int era ) : int

Usage Example

Пример #1
0
        private void SetMonthModeCalendarDayButtons()
        {
            DateTime firstDayOfMonth    = DateTimeHelper.DiscardDayTime(DisplayDate);
            int      lastMonthToDisplay = GetNumberOfDisplayedDaysFromPreviousMonth(firstDayOfMonth);

            bool        isMinMonth  = DateTimeHelper.CompareYearMonth(firstDayOfMonth, DateTime.MinValue) <= 0;
            bool        isMaxMonth  = DateTimeHelper.CompareYearMonth(firstDayOfMonth, DateTime.MaxValue) >= 0;
            int         daysInMonth = _calendar.GetDaysInMonth(firstDayOfMonth.Year, firstDayOfMonth.Month);
            CultureInfo culture     = DateTimeHelper.GetCulture(this);

            int count = ROWS * COLS;

            for (int childIndex = COLS; childIndex < count; childIndex++)
            {
                CalendarDayButton childButton = _monthView.Children[childIndex] as CalendarDayButton;
                Debug.Assert(childButton != null);

                int dayOffset = childIndex - lastMonthToDisplay - COLS;
                if ((!isMinMonth || (dayOffset >= 0)) && (!isMaxMonth || (dayOffset < daysInMonth)))
                {
                    DateTime dateToAdd = _calendar.AddDays(firstDayOfMonth, dayOffset);
                    SetMonthModeDayButtonState(childButton, dateToAdd);
                    childButton.DataContext = dateToAdd;
                    childButton.SetContentInternal(DateTimeHelper.ToDayString(dateToAdd, culture));
                }
                else
                {
                    SetMonthModeDayButtonState(childButton, null);
                    childButton.DataContext = null;
                    childButton.SetContentInternal(DateTimeHelper.ToDayString(null, culture));
                }
            }
        }
All Usage Examples Of System.Globalization.Calendar::GetDaysInMonth