Incorrect leap second handling in new AbsoluteDate(DateComponents, TimeComponents, TimeScale)
Failing test case below. Using the constructor AbsoluteDate(DateComponents, TimeComponents, TimeScale)
adds one second when the time is during a leap second. Seems to be due to UTCScale.offsetToTAI
expects that timeComponents
is 23:59:60.5
during a leap second, but it is actually 24:00:00.5
. So the bug might actually be in the TimeComponents
constructor.
@Test
public void testLeap() {
TimeScale utc = context.getTimeScales().getUTC();
// During 2012 leap second
final DateComponents dc = new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 56108);
final TimeComponents tc = new TimeComponents(86400.5);
final AbsoluteDate date = new AbsoluteDate(dc, tc, utc);
final AbsoluteDate date1 = new AbsoluteDate(dc, utc).shiftedBy(86400.5);
Assert.assertEquals(date, date1);
}
Same as #247 (closed) but for the constructor. Strangely it seems that #247 (closed) was fixed by working around this bug in the constructor.