AbsoluteDate.getCompnents(utc) throws "non-existent time 23:59:61"
Another bug in the series of leap second and date edge cases. The call to getComponents(utc)
in the test case below throws an exception:
@Test
public void testGetComponentsEndOfLeap() {
// setup
TimeScale utc = TimeScalesFactory.getUTC();
// create date as close as possible to the end of the leap second yet still
// within the leap second.
AbsoluteDate t = new AbsoluteDate(2012, 7, 1, 0, 0, 0, utc)
.shiftedBy(-1)
.shiftedBy(FastMath.nextDown(1.0));
// action
DateTimeComponents dtc = t.getComponents(utc);
// verify
Assert.assertEquals(2012, dtc.getDate().getYear());
Assert.assertEquals(6, dtc.getDate().getMonth());
Assert.assertEquals(30, dtc.getDate().getDay());
Assert.assertEquals(23, dtc.getTime().getHour());
Assert.assertEquals(59, dtc.getTime().getMinute());
Assert.assertEquals(60.99999999999999, dtc.getTime().getSecond(), 0);
}
Here is the exception:
org.orekit.errors.OrekitIllegalArgumentException: non-existent time 23:59:61
at org.orekit.time.TimeComponents.<init>(TimeComponents.java:113)
at org.orekit.time.TimeComponents.<init>(TimeComponents.java:88)
at org.orekit.time.AbsoluteDate.getComponents(AbsoluteDate.java:1096)
at org.orekit.time.AbsoluteDateTest.testGetComponentsEndOfLeap(AbsoluteDateTest.java:957)
Might be related to #149 (closed) since a different TimeComponents
constructor is used during a leap second.