Commit 6550a89f authored by Evan Ward's avatar Evan Ward
Browse files

Fix #880 wrong UTC offset when rounding up

Previously the UTC offset was not copied from the original
TimeComponents to the rounded TimeComponents.
parent 9d621ecf
......@@ -21,6 +21,9 @@
</properties>
<body>
<release version="11.1" date="TBD" description="TBD">
<action dev="evan" type="fix" issue="880">
Fix UTC offset in DateTimeComponents.toString(int, int)
</action>
<action dev="luc" type="fix" issue="849">
Added detector to FieldEventHandler.init arguments list.
</action>
......
......@@ -309,7 +309,7 @@ public class DateTimeComponents implements Serializable, Comparable<DateTimeComp
}
}
roundedDate = new DateComponents(j2000);
roundedTime = new TimeComponents(hour, minute, second);
roundedTime = new TimeComponents(hour, minute, second, time.getMinutesFromUTC());
}
return roundedDate.toString() + 'T' +
roundedTime.toStringWithoutUtcOffset(secondsFormat) +
......
......@@ -195,4 +195,14 @@ public class DateTimeComponentsTest {
MatcherAssert.assertThat(dtc.toString(minuteDuration, 14), CoreMatchers.is(full));
}
@Test
public void testToStringRoundingUtcOffset() {
DateTimeComponents dtc =
new DateTimeComponents(new DateComponents(2000, 12, 31), new TimeComponents(23, 59, 59.9, -92));
MatcherAssert.assertThat(dtc.toString(60), CoreMatchers.is("2000-12-31T23:59:59.900-01:32"));
MatcherAssert.assertThat(dtc.toString(60, 3), CoreMatchers.is("2000-12-31T23:59:59.900-01:32"));
MatcherAssert.assertThat(dtc.toString(60, 0), CoreMatchers.is("2001-01-01T00:00:00-01:32"));
MatcherAssert.assertThat(dtc.toString(60, 14), CoreMatchers.is("2000-12-31T23:59:59.90000000000000-01:32"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment