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

Equals() public méthode

Compares two Interval instance to see if they contain the same information.
This routine takes into account the equivalence of certain time intervals (e.g. 1Y = 12M and 1W = 7D).
public Equals ( Interval other ) : bool
other Interval The other Interval instance.
Résultat bool
        public bool Equals(Interval other)
        {
            if (period == other.period)
                return (multiplier == other.multiplier);

            // Handle 1Y == 12M equivalence
            if (period == Period.YEAR) {
                if (other.period == Period.MONTH)
                    return ((multiplier * 12) == other.multiplier);
                return (false);
            }
            if (period == Period.MONTH) {
                if (other.period == Period.YEAR)
                    return (multiplier == (other.multiplier * 12));
                return (false);
            }

            // Handle 1W == 7D equivalence
            if (period == Period.WEEK) {
                if (other.period == Period.DAY)
                    return ((multiplier * 7) == other.multiplier);
                return (false);
            }
            if (period == Period.DAY) {
                if (other.period == Period.WEEK)
                    return (multiplier == (other.multiplier * 7));
                return (false);
            }

            return (false);
        }

Same methods

Interval::Equals ( object other ) : bool