use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration in project webtools.sourceediting by eclipse.
the class FnAdjustDateTimeToTimeZone method adjustdateTime.
/**
* Evaluate the function using the arguments passed.
*
* @param args
* Result from the expressions evaluation.
* @param sc
* Result of static context operation.
* @throws DynamicError
* Dynamic error.
* @return Result of the fn:dateTime operation.
*/
public static ResultSequence adjustdateTime(Collection args, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expectedArgs());
// get args
Iterator argiter = cargs.iterator();
ResultSequence arg1 = (ResultSequence) argiter.next();
if (arg1.empty()) {
return ResultBuffer.EMPTY;
}
ResultSequence arg2 = null;
if (argiter.hasNext()) {
arg2 = (ResultSequence) argiter.next();
}
XSDateTime dateTime = (XSDateTime) arg1.item(0);
XSDayTimeDuration timezone = null;
if (arg2 != null && arg2.empty()) {
if (dateTime.timezoned()) {
CalendarType localized = new XSDateTime(dateTime.calendar(), null);
return localized;
} else {
return arg1;
}
} else if (arg2 == null) {
CalendarType localized = new XSDateTime(dateTime.normalizeCalendar(dateTime.calendar(), dateTime.tz()), null);
return localized;
}
timezone = (XSDayTimeDuration) arg2.item(0);
if (timezone.lt(minDuration, dynamicContext) || timezone.gt(maxDuration, dynamicContext)) {
throw DynamicError.invalidTimezone();
}
if (dateTime.tz() == null) {
return new XSDateTime(dateTime.calendar(), timezone);
}
XMLGregorianCalendar xmlCalendar = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) dateTime.normalizeCalendar(dateTime.calendar(), dateTime.tz()));
Duration duration = _datatypeFactory.newDuration(timezone.getStringValue());
xmlCalendar.add(duration);
return new XSDateTime(xmlCalendar.toGregorianCalendar(), timezone);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration in project webtools.sourceediting by eclipse.
the class FnCurrentDate method current_date.
/**
* Current-Date operation.
*
* @param args
* Result from the expressions evaluation.
* @param dc
* Result of dynamic context operation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:current-date operation.
*/
public static ResultSequence current_date(Collection args, DynamicContext dc) throws DynamicError {
assert args.size() == 0;
XSDayTimeDuration tz = new XSDayTimeDuration(dc.getTimezoneOffset());
AnyType res = new XSDate(dc.getCurrentDateTime(), tz);
return ResultSequenceFactory.create_new(res);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration in project webtools.sourceediting by eclipse.
the class FnCurrentTime method current_time.
/**
* Current-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-time operation.
*/
public static ResultSequence current_time(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 XSTime(dc.getCurrentDateTime(), tz);
return ResultSequenceFactory.create_new(res);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration 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.XSDayTimeDuration in project webtools.sourceediting by eclipse.
the class FnAdjustDateToTimeZone method expectedArgs.
/**
* Obtain a list of expected arguments.
*
* @return Result of operation.
*/
public static synchronized Collection expectedArgs() {
if (_expected_args == null) {
_expected_args = new ArrayList();
_expected_args.add(new SeqType(new XSDate(), SeqType.OCC_QMARK));
_expected_args.add(new SeqType(new XSDayTimeDuration(), SeqType.OCC_QMARK));
}
return _expected_args;
}
Aggregations