garydgregory commented on PR #1780:
URL: https://github.com/apache/commons-lang/pull/1780#issuecomment-5500845135
There is one case this PR breaks that I just added to demonstrate the issue:
```java
@Test
void testFormatPeriodWithoutMonthsAfterLeapDayAnniversary() {
final TimeZone timeZone = TimeZone.getTimeZone("UTC");
final Calendar start = Calendar.getInstance(timeZone);
start.clear();
// 2020 was not a leap year
start.set(2020, Calendar.FEBRUARY, 29);
final Calendar end = Calendar.getInstance(timeZone);
end.clear();
// 2021 was not a leap year
end.set(2021, Calendar.MARCH, 1);
assertEquals("1 years 1 days",
DurationFormatUtils.formatPeriod(start.getTimeInMillis(),
end.getTimeInMillis(), "y' years 'd' days'", false, timeZone));
}
```
There is no standard for normalizing dates in non-leap years.
The `main` branch code normalizes Feb 29 2020 to Feb 28 2020, to stay in the
same month.
The PR reverses that to normalize Feb 29 to March 1 to keep chronological
order.
I'm not sure if switching the direction will have unintended consequence.
WDYT?
Or, is it possible for the PR to keep the current normalization?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]