"Expected at most one xs:date", args[0]);
} else if (args[1].hasMany()) {
throw new XPathException(this, ErrorCodes.XPTY0004,
"Expected at most one xs:time", args[1]);
} else {
final DateValue dv = (DateValue)args[0].itemAt(0);
final TimeValue tv = (TimeValue)args[1].itemAt(0);
if (!dv.getTimezone().isEmpty()) {
if (!tv.getTimezone().isEmpty()) {
if (!((DayTimeDurationValue)dv.getTimezone().itemAt(0))
.compareTo(null, Constants.EQ,
((DayTimeDurationValue)tv.getTimezone().itemAt(0)))) {
final ValueSequence argsSeq = new ValueSequence();
argsSeq.add(dv);
argsSeq.add(tv);
throw new XPathException(this, ErrorCodes.FORG0008,
"Operands have different timezones", argsSeq);
}
}
}
String dtv = ((DateTimeValue)dv.convertTo(Type.DATE_TIME)).getTrimmedCalendar().toXMLFormat();
if (dv.getTimezone().isEmpty()) {
dtv = dtv.substring(0, dtv.length() - 8);
result = new DateTimeValue(dtv + tv.getStringValue());
} else if ("PT0S".equals(((DayTimeDurationValue)dv.getTimezone().itemAt(0)).getStringValue())) {
dtv = dtv.substring(0, dtv.length() - 9);
if (tv.getTimezone().isEmpty()) {
result = new DateTimeValue(dtv + tv.getStringValue() + "Z");
} else {
result = new DateTimeValue(dtv + tv.getStringValue());