예제 #1
0
        /// <summary>
        /// Returns object <see cref="Month"/> of last month
        /// </summary>
        /// <param name="month">Number of current month</param>
        /// <param name="year">Number of current year</param>
        /// <Returns>Object <see cref="Month"/></Returns>
        public Month PrevMonth(int month, int year)
        {
            SetCurrentMonth(month, year);

            Year currentYear;
            if (_currentMonth.GetThisMonth() != 1)
            {
                currentYear = GetYear(_currentMonth.GetThisYear());
                _currentMonth = currentYear.GetMonth(_currentMonth.GetThisMonth() - 1);
                return _currentMonth;
            }
            currentYear = GetYear(_currentMonth.GetThisYear() - 1);
            if (currentYear != null)
                _currentMonth = currentYear.GetMonth(12);
            else
            {
                _years.Add(new Year(_currentMonth.GetThisYear() - 1));
                _currentMonth = new Month(12, _currentMonth.GetThisYear() - 1);
            }
            return _currentMonth;
        }
예제 #2
0
 /// <summary>
 /// Set athe current mont
 /// </summary>
 /// <param name="month">Number of the month</param>
 /// <param name="year">Number of the year</param>
 public void SetCurrentMonth(int month, int year)
 {
     var currentYear = GetYear(year);
     _currentMonth = currentYear != null ? currentYear.GetMonth(month) : new Month(month, year);
 }
예제 #3
0
 /// <summary>
 /// Returns object <see cref="Month"/> of current month (for time if not usage <see cref="SetCurrentMonth"/>)
 /// </summary>
 /// <Returns>Object <see cref="Month"/></Returns>
 public Month CurrentMonth()
 {
     var currentYear = GetYear(DateTime.Now.Year);
     if (_currentMonth == null)
     {
         if (currentYear != null)
             _currentMonth = currentYear.GetMonth(DateTime.Now.Month);
         else
         {
             _years.Add(new Year(DateTime.Now.Year));
             _currentMonth = new Month(DateTime.Now.Month, DateTime.Now.Year);
         }
     }
     return _currentMonth;
 }