public <U extends IValue, V extends IValue> Result<U> fieldUpdate(
String name, Result<V> repl, TypeStore store) {
Type replType = repl.getType();
IValue replValue = repl.getValue();
IDateTime dt = getValue();
// Individual fields
int year = dt.getYear();
int month = dt.getMonthOfYear();
int day = dt.getDayOfMonth();
int hour = dt.getHourOfDay();
int minute = dt.getMinuteOfHour();
int second = dt.getSecondOfMinute();
int milli = dt.getMillisecondsOfSecond();
int tzOffsetHour = dt.getTimezoneOffsetHours();
int tzOffsetMin = dt.getTimezoneOffsetMinutes();
try {
if (name.equals("year")) {
if (dt.isTime()) {
throw new UnsupportedOperation("Can not update the year on a time value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
year = ((IInteger) replValue).intValue();
} else if (name.equals("month")) {
if (dt.isTime()) {
throw new UnsupportedOperation("Can not update the month on a time value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
month = ((IInteger) replValue).intValue();
} else if (name.equals("day")) {
if (dt.isTime()) {
throw new UnsupportedOperation("Can not update the day on a time value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
day = ((IInteger) replValue).intValue();
} else if (name.equals("hour")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the hour on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
hour = ((IInteger) replValue).intValue();
} else if (name.equals("minute")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the minute on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
minute = ((IInteger) replValue).intValue();
} else if (name.equals("second")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the second on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
second = ((IInteger) replValue).intValue();
} else if (name.equals("millisecond")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the millisecond on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
milli = ((IInteger) replValue).intValue();
} else if (name.equals("timezoneOffsetHours")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the timezone offset hours on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
tzOffsetHour = ((IInteger) replValue).intValue();
} else if (name.equals("timezoneOffsetMinutes")) {
if (dt.isDate()) {
throw new UnsupportedOperation("Can not update the timezone offset minutes on a date value",ctx.getCurrentAST());
}
if (!replType.isInteger()) {
throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
}
tzOffsetMin = ((IInteger) replValue).intValue();
} else {
throw new UndeclaredField(name, getTypeFactory().dateTimeType(), ctx.getCurrentAST());
}
IDateTime newdt = null;
if (dt.isDate()) {
newdt = getValueFactory().date(year, month, day);
} else if (dt.isTime()) {
newdt = getValueFactory().time(hour, minute, second, milli, tzOffsetHour, tzOffsetMin);
} else {