Skip to content

Commit

Permalink
Simplify index calculation in buildSetPositionsList(…)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Jan 28, 2024
1 parent e47a0a8 commit 8a72d61
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/src/iteration/set_positions_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,10 @@ Iterable<DateTime> buildSetPositionsList(

final timeList = timeSet.toList(growable: false);
for (final setPosition in rrule.bySetPositions) {
int datePosition;
int timePosition;

if (setPosition < 0) {
datePosition = (setPosition / timeList.length).floor();
timePosition = setPosition % timeList.length;
} else {
assert(setPosition > 0);
datePosition = ((setPosition - 1) / timeList.length).floor();
timePosition = (setPosition - 1) % timeList.length;
}
final correctedSetPosition =
setPosition < 0 ? setPosition : setPosition - 1;
final datePosition = correctedSetPosition ~/ timeList.length;
final timePosition = correctedSetPosition % timeList.length;

if (datePosition >= dateIndices.length ||
-datePosition > dateIndices.length) {
Expand Down

0 comments on commit 8a72d61

Please sign in to comment.