Skip to content

Commit

Permalink
Arithmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 29, 2019
1 parent 3927539 commit 36fc86b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Expand Up @@ -68,7 +68,7 @@ public List<T> apply(T date) {
// construct a list of possible month days..
final int numDaysInMonth = YearMonth.of(getYear(date), getMonth(date)).lengthOfMonth();
for (final int monthDay : monthDayList) {
if (monthDay == 0 || monthDay <= -numDaysInMonth || monthDay > numDaysInMonth) {
if (monthDay == 0 || monthDay < -numDaysInMonth || monthDay > numDaysInMonth) {
if (log.isTraceEnabled()) {
log.trace("Invalid day of month: " + monthDay);
}
Expand All @@ -84,7 +84,7 @@ public List<T> apply(T date) {
if (numDaysInMonth < -monthDay) {
continue;
}
candidate = withTemporalField(date, DAY_OF_MONTH, numDaysInMonth + monthDay);
candidate = withTemporalField(date, DAY_OF_MONTH, numDaysInMonth + 1 + monthDay);
}
retVal.add(candidate);
};
Expand Down
Expand Up @@ -38,7 +38,7 @@ public List<T> transform(List<T> dates) {
for (final T date : dates) {
final int numWeeksInYear = (int) IsoFields.WEEK_OF_WEEK_BASED_YEAR.rangeRefinedBy(date).getMaximum();
for (final Integer weekNo : weekNoList) {
if (weekNo == 0 || weekNo <= -numWeeksInYear || weekNo > numWeeksInYear) {
if (weekNo == 0 || weekNo < -numWeeksInYear || weekNo > numWeeksInYear) {
if (log.isTraceEnabled()) {
log.trace("Invalid week of year: " + weekNo);
}
Expand All @@ -54,7 +54,7 @@ public List<T> transform(List<T> dates) {
if (numWeeksInYear < -weekNo) {
continue;
}
candidate = withTemporalField(date, ALIGNED_WEEK_OF_YEAR, numWeeksInYear + weekNo);
candidate = withTemporalField(date, ALIGNED_WEEK_OF_YEAR, numWeeksInYear + 1 + weekNo);
}
weekNoDates.add(candidate);
}
Expand Down
Expand Up @@ -67,7 +67,7 @@ public List<T> apply(T date) {
// construct a list of possible year days..
final int numDaysInYear = Year.of(getYear(date)).length();
for (final int yearDay : yearDayList) {
if (yearDay == 0 || yearDay <= -numDaysInYear || yearDay > numDaysInYear) {
if (yearDay == 0 || yearDay < -numDaysInYear || yearDay > numDaysInYear) {
if (log.isTraceEnabled()) {
log.trace("Invalid day of year: " + yearDay);
}
Expand All @@ -83,7 +83,7 @@ public List<T> apply(T date) {
if (numDaysInYear < -yearDay) {
continue;
}
candidate = withTemporalField(date, DAY_OF_YEAR, numDaysInYear + yearDay);
candidate = withTemporalField(date, DAY_OF_YEAR, numDaysInYear + 1 + yearDay);
}
retVal.add(candidate);
}
Expand Down

0 comments on commit 36fc86b

Please sign in to comment.