/// <summary> /// Mathematical subtraction between this duration stored and the supplied /// duration of time (of type XSYearMonthDuration) /// </summary> /// <param name="arg"> /// The duration of time to subtract </param> /// <returns> New XSYearMonthDuration 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) { XSYearMonthDuration val = (XSYearMonthDuration)NumericType.get_single_type(arg, typeof(XSYearMonthDuration)); int res = monthValue() - val.monthValue(); return(ResultSequenceFactory.create_new(new XSYearMonthDuration(res))); }
/// <summary> /// Mathematical addition operator between this XSDate and a supplied result /// sequence (XDTYearMonthDuration and XDTDayTimeDuration are only valid /// ones). /// </summary> /// <param name="arg"> /// The supplied ResultSequence that is on the right of the minus /// operator. If arg is an XDTYearMonthDuration or an /// XDTDayTimeDuration the result will be a XSDate of the result /// of the current date minus the duration of time supplied. </param> /// <returns> New ResultSequence consisting of the result of the mathematical /// minus operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence plus(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public virtual ResultSequence plus(ResultSequence arg) { if (arg.size() != 1) { DynamicError.throw_type_error(); } Item at = arg.first(); try { if (at is XSYearMonthDuration) { XSYearMonthDuration val = (XSYearMonthDuration)at; XSDate res = (XSDate)clone(); res.calendar().add(Calendar.MONTH, val.monthValue()); return(ResultSequenceFactory.create_new(res)); } else if (at is XSDayTimeDuration) { XSDayTimeDuration val = (XSDayTimeDuration)at; XSDate res = (XSDate)clone(); // We only need to add the Number of days dropping the rest. int days = val.days(); if (val.negative()) { days *= -1; } res.calendar().add(Calendar.DAY_OF_MONTH, days); res.calendar().add(Calendar.MILLISECOND, (int)(val.time_value() * 1000.0)); return(ResultSequenceFactory.create_new(res)); } else { DynamicError.throw_type_error(); return(null); // unreach } } catch { Debug.Assert(false); return(null); } }
/// <summary> /// Mathematical division between this duration stored and the supplied /// duration of time (of type XSYearMonthDuration) /// </summary> /// <param name="arg"> /// The duration of time to divide by </param> /// <returns> New XSYearMonthDuration 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; int ret = 0; if (!dt.zero()) { ret = (int)Math.Round(monthValue() / dt.double_value()); } return(ResultSequenceFactory.create_new(new XSYearMonthDuration(ret))); } else if (at is XSDecimal) { XSDecimal dt = (XSDecimal)at; int ret = 0; if (!dt.zero()) { ret = (int)Math.Round(monthValue() / dt.Value); } return(ResultSequenceFactory.create_new(new XSYearMonthDuration(ret))); } else if (at is XSYearMonthDuration) { XSYearMonthDuration md = (XSYearMonthDuration)at; double res = (double)monthValue() / md.monthValue(); return(ResultSequenceFactory.create_new(new XSDecimal(new decimal(res)))); } else { DynamicError.throw_type_error(); return(null); // unreach } }
private ResultSequence minusXSYearMonthDuration(AnyType at) { XSYearMonthDuration val = (XSYearMonthDuration)at; try { XSDate res = (XSDate)clone(); res.calendar().add(Calendar.MONTH, val.monthValue() * -1); return(ResultSequenceFactory.create_new(res)); } catch { } return(null); }
/// <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> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean eq(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override bool eq(AnyType arg, DynamicContext dynamicContext) { if (arg is XSDayTimeDuration) { XSDayTimeDuration dayTimeDuration = (XSDayTimeDuration)arg; return(monthValue() == 0 && dayTimeDuration.value() == 0.0); } else if (arg is XSYearMonthDuration) { XSYearMonthDuration yearMonthDuration = (XSYearMonthDuration)arg; return(monthValue() == yearMonthDuration.monthValue()); } XSDuration val = (XSDuration)NumericType.get_single_type(arg, typeof(XSDuration)); return(base.eq(val, dynamicContext)); }
/// <summary> /// Mathematical addition operator between this XSDateTime and a supplied /// result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only /// valid ones). /// </summary> /// <param name="arg"> /// The supplied ResultSequence that is on the right of the minus /// operator. If arg is an XDTYearMonthDuration or an /// XDTDayTimeDuration the result will be a XSDateTime of the /// result of the current date minus the duration of time /// supplied. </param> /// <returns> New ResultSequence consisting of the result of the mathematical /// minus operation. </returns> public virtual ResultSequence plus(ResultSequence arg) { if (arg.size() != 1) { DynamicError.throw_type_error(); } Item at = arg.first(); try { if (at is XSYearMonthDuration) { XSYearMonthDuration val = (XSYearMonthDuration)at; XSDateTime res = (XSDateTime)clone(); res.calendar().add(Calendar.MONTH, val.monthValue()); return(ResultSequenceFactory.create_new(res)); } else if (at is XSDayTimeDuration) { XSDuration val = (XSDuration)at; XSDateTime res = (XSDateTime)clone(); XMLGregorianCalendar xmlCal = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar)calendar()); Duration dtduration = _datatypeFactory.newDuration(val.StringValue); xmlCal.add(dtduration); res = new XSDateTime(xmlCal.toGregorianCalendar(), res.tz()); return(ResultSequenceFactory.create_new(res)); } else { DynamicError.throw_type_error(); return(null); // unreach } } catch { Debug.Assert(false); return(null); } }
/// <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> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean gt(AnyType arg, org.eclipse.wst.xml.xpath2.api.DynamicContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override bool gt(AnyType arg, DynamicContext context) { XSYearMonthDuration val = (XSYearMonthDuration)NumericType.get_single_type(arg, typeof(XSYearMonthDuration)); return(monthValue() > val.monthValue()); }