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;
        }