use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime in project webtools.sourceediting by eclipse.
the class FnYearFromDateTime method year_from_date_time.
/**
* Year-from-DateTime operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:year-from-dateTime operation.
*/
public static ResultSequence year_from_date_time(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDateTime dt = (XSDateTime) arg1.first();
int res = dt.year();
return new XSInteger(BigInteger.valueOf(res));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime in project webtools.sourceediting by eclipse.
the class FnSecondsFromDateTime method seconds_from_date_time.
/**
* Seconds-from-dateTime operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:seconds-from-dateTime operation.
*/
public static ResultSequence seconds_from_date_time(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
XSDateTime dt = (XSDateTime) arg1.first();
double res = dt.second();
return new XSDecimal(new BigDecimal(res));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime in project webtools.sourceediting by eclipse.
the class FnCurrentDateTime method current_dateTime.
/**
* Current-Date-Time operation.
*
* @param args
* Result from the expressions evaluation.
* @param dc
* Result of dynamic context operation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:current-dateTime operation.
*/
public static ResultSequence current_dateTime(Collection args, DynamicContext dc) throws DynamicError {
assert args.size() == 0;
Duration d = dc.getTimezoneOffset();
XSDayTimeDuration tz = new XSDayTimeDuration(0, d.getHours(), d.getMinutes(), 0.0, d.getSign() == -1);
AnyType res = new XSDateTime(dc.getCurrentDateTime(), tz);
return ResultSequenceFactory.create_new(res);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDateTime in project webtools.sourceediting by eclipse.
the class XSDateTime method plus.
/**
* Mathematical addition operator between this XSDateTime and a supplied
* result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only
* valid ones).
*
* @param 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.
* @return New ResultSequence consisting of the result of the mathematical
* minus operation.
*/
public ResultSequence plus(ResultSequence arg) throws DynamicError {
if (arg.size() != 1)
DynamicError.throw_type_error();
Item at = arg.first();
try {
if (at instanceof XSYearMonthDuration) {
XSYearMonthDuration val = (XSYearMonthDuration) at;
XSDateTime res = (XSDateTime) clone();
res.calendar().add(Calendar.MONTH, val.monthValue());
return ResultSequenceFactory.create_new(res);
} else if (at instanceof XSDayTimeDuration) {
XSDuration val = (XSDuration) at;
XSDateTime res = (XSDateTime) clone();
XMLGregorianCalendar xmlCal = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) calendar());
Duration dtduration = _datatypeFactory.newDuration(val.getStringValue());
xmlCal.add(dtduration);
res = new XSDateTime(xmlCal.toGregorianCalendar(), res.tz());
return ResultSequenceFactory.create_new(res);
} else {
DynamicError.throw_type_error();
// unreach
return null;
}
} catch (CloneNotSupportedException err) {
assert false;
return null;
}
}
Aggregations