BudgetAnalyser.Engine.DateTimeExtension.DurationInMonths C# (CSharp) Метод

DurationInMonths() публичный статический Метод

Works out the duration in whole months between the two dates. The end date must be at least one whole calendar month ahead of the instance date to deemed one month.
public static DurationInMonths ( this minDate, System.DateTime maxDate ) : int
minDate this
maxDate System.DateTime
Результат int
        public static int DurationInMonths(this DateTime minDate, DateTime maxDate)
        {
            var durationInMonths = (int) Math.Round(maxDate.Subtract(minDate).TotalDays / 30, 0);
            if (durationInMonths <= 0)
            {
                durationInMonths = 1;
            }

            return durationInMonths;
        }