Exemple #1
0
        /// <summary>
        /// Equals method overloaded to compare two values of the same data type.
        /// </summary>
        /// <param name="obj">The object to compare with.</param>
        /// <returns>true, if both values are equals, otherwise false.</returns>
        public override bool Equals(object obj)
        {
            DaytimeDuration compareTo = obj as DaytimeDuration;

            if (compareTo == null)
            {
                return(base.Equals(obj));
            }

            return(_days == compareTo._days && _hours == compareTo._hours && _minutes == compareTo._minutes && _seconds == compareTo._seconds && _negative == compareTo._negative);
        }
Exemple #2
0
        /// <summary>
        /// Evaluates the function.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <param name="args">The function arguments.</param>
        /// <returns>The result value of the function evaluation.</returns>
        public override EvaluationValue Evaluate(EvaluationContext context, params IFunctionParameter[] args)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            DateTime baseDate = GetDateTimeArgument(args, 0);

            typ.DaytimeDuration dayTimeDuration = GetDaytimeDurationArgument(args, 1);

            baseDate = baseDate.AddDays(dayTimeDuration.Days * -1);
            baseDate = baseDate.AddHours(dayTimeDuration.Hours * -1);
            baseDate = baseDate.AddMinutes(dayTimeDuration.Minutes * -1);
            baseDate = baseDate.AddSeconds(dayTimeDuration.Seconds * -1);

            return(new EvaluationValue(baseDate, DataTypeDescriptor.DateTime));
        }