Beispiel #1
0
        /// <summary>
        /// Implicit-Timezone operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:implicit-timezone operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence implicit_timezone(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence implicit_timezone(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            AnyType res = new XSDayTimeDuration(dc.TimezoneOffset);

            return(ResultSequenceFactory.create_new(res));
        }
Beispiel #2
0
        /// <summary>
        /// Current-Date operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:current-date operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence current_date(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence current_date(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            XSDayTimeDuration tz  = new XSDayTimeDuration(dc.TimezoneOffset);
            AnyType           res = new XSDate(dc.CurrentDateTime, tz);

            return(ResultSequenceFactory.create_new(res));
        }
        /// <summary>
        /// Current-Time operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="dc">
        ///            Result of dynamic context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:current-time operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence current_time(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence current_time(ICollection args, DynamicContext dc)
        {
            Debug.Assert(args.Count == 0);

            var d = dc.TimezoneOffset;
            XSDayTimeDuration tz = new XSDayTimeDuration(0, d.Hours, d.Minutes, 0.0, d.Sign == -1);

            AnyType res = new XSTime(dc.CurrentDateTime, tz);

            return(ResultSequenceFactory.create_new(res));
        }
Beispiel #4
0
        /// <summary>
        /// Evaluate the function using the arguments passed.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="sc">
        ///            Result of static context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of the fn:dateTime operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence adjustDate(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence adjustDate(ICollection args, DynamicContext dc)
        {
            ICollection cargs = Function.convert_arguments(args, expectedArgs());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }
            ResultSequence arg2 = ResultBuffer.EMPTY;

            if (argiter.MoveNext())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                arg2 = (ResultSequence)argiter.Current;
            }

            XSDate            date     = (XSDate)arg1.item(0);
            XSDayTimeDuration timezone = null;

            if (arg2.empty())
            {
                if (date.timezoned())
                {
                    XSDate localized = new XSDate(date.calendar(), null);
                    return(localized);
                }
                return(arg1);
            }

            timezone = (XSDayTimeDuration)arg2.item(0);
            if (timezone.lt(minDuration, dc) || timezone.gt(maxDuration, dc))
            {
                throw DynamicError.invalidTimezone();
            }

            if (date.tz() == null)
            {
                return(new XSDate(date.calendar(), timezone));
            }

            XMLGregorianCalendar xmlCalendar = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar)date.normalizeCalendar(date.calendar(), date.tz()));

            Duration duration = _datatypeFactory.newDuration(timezone.StringValue);

            xmlCalendar.add(duration);

            return(new XSDate(xmlCalendar.toGregorianCalendar(), timezone));
        }
        /// <summary>
        /// Evaluate the function using the arguments passed.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <param name="sc">
        ///            Result of static context operation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of the fn:dateTime operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence adjustTime(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dc) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence adjustTime(ICollection args, DynamicContext dc)
        {
            ICollection cargs = Function.convert_arguments(args, expectedArgs());

            // get args
            IEnumerator argiter = cargs.GetEnumerator();

            argiter.MoveNext();
            ResultSequence arg1 = (ResultSequence)argiter.Current;

            if (arg1 == null || arg1.empty())
            {
                return(ResultBuffer.EMPTY);
            }
            ResultSequence arg2 = ResultBuffer.EMPTY;

            if (argiter.MoveNext())
            {
                arg2 = (ResultSequence)argiter.Current;
            }
            XSTime            time     = (XSTime)arg1.first();
            XSDayTimeDuration timezone = null;

            if (arg2.empty())
            {
                if (time.timezoned())
                {
                    XSTime localized = new XSTime(time.calendar(), null);
                    return(localized);
                }
                else
                {
                    return(arg1);
                }
            }


            XMLGregorianCalendar xmlCalendar = null;

            if (time.tz() != null)
            {
                xmlCalendar = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar)time.normalizeCalendar(time.calendar(), time.tz()));
            }
            else
            {
                xmlCalendar = _datatypeFactory.newXMLGregorianCalendarTime(time.hour(), time.minute(), (int)time.second(), 0);
            }

            timezone = (XSDayTimeDuration)arg2.first();
            if (timezone.lt(minDuration, dc) || timezone.gt(maxDuration, dc))
            {
                throw DynamicError.invalidTimezone();
            }

            if (time.tz() == null)
            {
                return(new XSTime(time.calendar(), timezone));
            }

            Duration duration = _datatypeFactory.newDuration(timezone.StringValue);

            xmlCalendar.add(duration);

            return(new XSTime(xmlCalendar.toGregorianCalendar(), timezone));
        }