public DateTime GetPrevious(DateTime fromDate)
        {
            DateTime date = fromDate;

            while (!this.MonthMatches(date))
            {
                date = date.AddMonths(1);
            }

            date = date.AddYears(-1);
            return(RelativeDate.GetDate(date.Year, date.Month, this.WeeksInMonth, this.DaysOfWeekExt));
        }
Exemple #2
0
        public DateTime GetPrevious(DateTime fromDate)
        {
            if (this.MonthCount <= 0)
            {
                throw new InvalidOperationException($"Invalid Month Count property value ({this.MonthCount})");
            }

            DateTime date = fromDate;

            while (!this.DateMatches(date))
            {
                date = date.AddDays(1);
            }

            date = date.AddMonths(-this.MonthCount);
            return(RelativeDate.GetDate(date.Year, date.Month, this.WeeksInMonth, this.DaysOfWeekExt));
        }
Exemple #3
0
        protected bool DateMatches(DateTime date)
        {
            DateTime matchDate = RelativeDate.GetDate(date.Year, date.Month, this.WeeksInMonth, this.DaysOfWeekExt);

            return(matchDate == date.Date);
        }