#1517·CoreNLP

SUTime: timexDateValue reports the end hour for a one-hour range

Author: AngledLuffaCreated Sep 25, 2026Updated Sep 25, 2026

SUTime: timexDateValue reports the end hour for a one-hour range

Summary

JodaTimeUtils.timexDateValue(begin, end) renders a range spanning a single hour using the hour of end rather than begin. Every other granularity uses begin. A range covering the last hour of a day produces hour 24.

Reproduction

java
timexDateValue(2017-06-15T10:00Z, 2017-06-15T11:00Z)  ->  2017-06-15T11   expected T10
timexDateValue(2017-06-15T00:00Z, 2017-06-15T01:00Z)  ->  2017-06-15T01   expected T00
timexDateValue(2017-06-15T23:00Z, 2017-06-16T00:00Z)  ->  2017-06-15T24   expected T23

Other granularities are correct, which is what makes this look like a slip rather than a convention:

java
timexDateValue(2017-06-15T10:30Z, 2017-06-15T10:31Z)  ->  2017-06-15T10:30
timexDateValue(2017-06-15T00:00Z, 2017-06-16T00:00Z)  ->  2017-06-15
timexDateValue(2017-06-01T00:00Z, 2017-07-01T00:00Z)  ->  2017-06

Cause

JodaTimeUtils.java:1045, in the one-hour branch:

java
} else if(hrDiff == 1 || opts.forceDate){
  //(case: an hour)
  value.append(zeroPad(begin.getHourOfDay()+1,2));

Every sibling branch in the same method reads the start value directly:

java
value.append(zeroPad(begin.getMonthOfYear(),2));
value.append(zeroPad(begin.getDayOfMonth(),2));
value.append(zeroPad(begin.getHourOfDay(),2));      // the day-and-hour case, no +1
value.append(zeroPad(begin.getMinuteOfHour(),2));

Only the one-hour case adds one. Removing the +1 would make it consistent with the rest.

The hour 24 case follows from the same line: 23 + 1. ISO 8601 permits 24:00 as an end-of-day marker, but not as the start of a one-hour range, and TIMEX3 consumers are unlikely to expect it.

Reach

timexDateValue has no callers inside CoreNLP. The only reference is the two-argument overload delegating to the three-argument one, so nothing in SUTime or the annotators reaches this code, and it does not appear in a 2075-sentence golden corpus. It is public API, so external callers can hit it.

That also means a fix carries no risk to the shipped pipeline: no rule, annotator or test output changes.

Suggested fix

Drop the +1 at line 1045. Worth adding a test for the four cases above at the same time, since nothing currently covers this method.

If the +1 turns out to be deliberate — say, some consumer wanting the exclusive end — then the comment above it should say so, and the sibling branches are the ones that are wrong.