HandCoded.Finance.Interval.DividesDates C# (CSharp) Méthode

DividesDates() public méthode

Determines if an Interval will divide the time period delimited by two dates exactly.
public DividesDates ( Date first, Date last ) : bool
first Date The first date.
last Date The last date.
Résultat bool
        public bool DividesDates(Date first, Date last)
        {
            int				multiplier	= this.multiplier;
            Period			period		= this.period;

            if (period == Period.TERM)
                return (multiplier == 1);

            if (period == Period.WEEK) {
                period = Period.DAY;
                multiplier *= 7;
            }

            if (period == Period.YEAR) {
                if (first.Month		 != last.Month)			return (false);
                if (first.DayOfMonth != last.DayOfMonth)	return (false);

                return (((last.Year - first.Year) % multiplier) == 0);
            }

            if (period == Period.MONTH) {
                if (first.DayOfMonth != last.DayOfMonth)	return (false);

                return ((((last.Year - first.Year) * 12 + last.Month - first.Month) % multiplier) == 0);
            }

            return (((last.GetHashCode () - first.GetHashCode ()) % multiplier) == 0);
        }