/**
* Evaluate in a general context
*/
public Item evaluateItem(XPathContext context) throws XPathException {
final DateTimeValue dt = DateTimeValue.getCurrentDateTime(context);
final TypeHierarchy th = context.getConfiguration().getTypeHierarchy();
final int targetType = getItemType(th).getPrimitiveType();
switch (targetType) {
case StandardNames.XS_DATE_TIME:
return dt;
case StandardNames.XS_DATE:
return dt.convert(BuiltInAtomicType.DATE, true).asAtomic();
case StandardNames.XS_TIME:
return dt.convert(BuiltInAtomicType.TIME, true).asAtomic();
case StandardNames.XS_DAY_TIME_DURATION:
case StandardNames.XS_DURATION:
return dt.getComponent(Component.TIMEZONE);
default:
throw new IllegalArgumentException("Wrong target type for current date/time");
}
}