Beispiel #1
0
        /// <summary>
        /// Mathematical subtraction between this duration stored and the supplied
        /// duration of time (of type XSDayTimeDuration)
        /// </summary>
        /// <param name="arg">
        ///            The duration of time to subtract </param>
        /// <returns> New XSDayTimeDuration representing the resulting duration after
        ///         the subtraction </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence minus(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual ResultSequence minus(ResultSequence arg)
        {
            XSDuration val = (XSDuration)NumericType.get_single_type(arg, typeof(XSDayTimeDuration));

            double res = value() - val.value();

            return(ResultSequenceFactory.create_new(new XSDayTimeDuration(res)));
        }
Beispiel #2
0
        /// <summary>
        /// Mathematical division between this duration stored and the supplied
        /// duration of time (of type XSDayTimeDuration)
        /// </summary>
        /// <param name="arg">
        ///            The duration of time to divide by </param>
        /// <returns> New XSDayTimeDuration representing the resulting duration after
        ///         the division </returns>
        /// <exception cref="DynamicError"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence div(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public virtual ResultSequence div(ResultSequence arg)
        {
            if (arg.size() != 1)
            {
                DynamicError.throw_type_error();
            }

            Item at = arg.first();

            if (at is XSDouble)
            {
                XSDouble dt     = (XSDouble)at;
                double   retval = 0;

                if (dt.nan())
                {
                    throw DynamicError.nan();
                }

                if (!dt.zero())
                {
                    decimal ret = new decimal(0);

                    if (dt.infinite())
                    {
                        retval = value() / dt.double_value();
                    }
                    else
                    {
                        ret = new decimal(value());
                        ret = decimal.Divide(ret, new decimal(dt.double_value()));
                        var x = ret.ToString();
                        double.TryParse(x, out double r);
                        retval = r;
                    }
                }
                else
                {
                    throw DynamicError.overflowUnderflow();
                }

                return(ResultSequenceFactory.create_new(new XSDayTimeDuration(retval)));
            }
            else if (at is XSDecimal)
            {
                XSDecimal dt = (XSDecimal)at;

                decimal ret = new decimal(0);

                if (!dt.zero())
                {
                    ret = new decimal(value());
                    ret = decimal.Divide(ret, dt.Value);
                }
                else
                {
                    throw DynamicError.overflowUnderflow();
                }

                var x = ret.ToString();
                double.TryParse(x, out double r);
                var i = (int)r;
                return(ResultSequenceFactory.create_new(new XSDayTimeDuration(i)));
            }
            else if (at is XSDayTimeDuration)
            {
                XSDuration md = (XSDuration)at;

                decimal res = default;
                res = new decimal(this.value());
                decimal l = new decimal(md.value());
                res = decimal.Divide(res, l);

                return(ResultSequenceFactory.create_new(new XSDecimal(res)));
            }
            else
            {
                DynamicError.throw_type_error();
                return(null);                // unreach
            }
        }
Beispiel #3
0
        /// <summary>
        /// Comparison between this and the supplied duration of time.
        /// </summary>
        /// <param name="arg">
        ///            The duration of time to compare with </param>
        /// <returns> True if the supplied time represents a smaller duration than that
        ///         stored. False otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
        public virtual bool gt(AnyType arg, DynamicContext context)
        {
            XSDuration val = (XSDuration)NumericType.get_single_type(arg, typeof(XSDayTimeDuration));

            return(value() > val.value());
        }
Beispiel #4
0
        /// <summary>
        /// Equality comparison between this and the supplied duration of time.
        /// </summary>
        /// <param name="arg">
        ///            The duration of time to compare with </param>
        /// <returns> True if they both represent the duration of time. False otherwise </returns>
        /// <exception cref="DynamicError"> </exception>
        public virtual bool eq(AnyType arg, DynamicContext dynamicContext)
        {
            XSDuration val = (XSDuration)NumericType.get_single_type(arg, typeof(XSDuration));

            return(value() == val.value());
        }