Skip to content

Commit 5bab064

Browse files
committed
Replace "weekdays" with "days of the week" to avoid confusion
In a previous commit I wrote "weekdays" when I really meant "days of the week".
1 parent 559af0e commit 5bab064

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

app/src/main/java/org/gnucash/android/model/ScheduledAction.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,43 +241,43 @@ private long computeNextScheduledExecutionTimeStartingAt(long startTime) {
241241
* Computes the next time that this weekly scheduled action is supposed to be
242242
* executed starting at startTime.
243243
*
244-
* If no weekdays have been set (GnuCash desktop allows it), it will return a
244+
* If no days of the week have been set (GnuCash desktop allows it), it will return a
245245
* date in the future to ensure ScheduledActionService doesn't execute it.
246246
*
247247
* @param startTime LocalDateTime to use as start to compute the next schedule.
248248
*
249-
* @return Next run time as a LocalDateTime. A date in the future, if no weekdays
249+
* @return Next run time as a LocalDateTime. A date in the future, if no days of the week
250250
* were set in the Recurrence.
251251
*/
252252
@NonNull
253253
private LocalDateTime computeNextWeeklyExecutionStartingAt(LocalDateTime startTime) {
254254
if (mRecurrence.getByDays().isEmpty())
255255
return LocalDateTime.now().plusDays(1); // Just a date in the future
256256

257-
// Look into the week of startTime for another scheduled weekday
258-
for (int weekDay : mRecurrence.getByDays() ) {
259-
int jodaWeekDay = convertCalendarWeekdayToJoda(weekDay);
260-
LocalDateTime candidateNextDueTime = startTime.withDayOfWeek(jodaWeekDay);
257+
// Look into the week of startTime for another scheduled day of the week
258+
for (int dayOfWeek : mRecurrence.getByDays() ) {
259+
int jodaDayOfWeek = convertCalendarDayOfWeekToJoda(dayOfWeek);
260+
LocalDateTime candidateNextDueTime = startTime.withDayOfWeek(jodaDayOfWeek);
261261
if (candidateNextDueTime.isAfter(startTime))
262262
return candidateNextDueTime;
263263
}
264264

265-
// Return the first scheduled weekday from the next due week
266-
int firstScheduledWeekday = convertCalendarWeekdayToJoda(mRecurrence.getByDays().get(0));
265+
// Return the first scheduled day of the week from the next due week
266+
int firstScheduledDayOfWeek = convertCalendarDayOfWeekToJoda(mRecurrence.getByDays().get(0));
267267
return startTime.plusWeeks(mRecurrence.getMultiplier())
268-
.withDayOfWeek(firstScheduledWeekday);
268+
.withDayOfWeek(firstScheduledDayOfWeek);
269269
}
270270

271271
/**
272-
* Converts a java.util.Calendar weekday constant to the
272+
* Converts a java.util.Calendar day of the week constant to the
273273
* org.joda.time.DateTimeConstants equivalent.
274274
*
275-
* @param calendarWeekday weekday constant from java.util.Calendar
276-
* @return weekday constant equivalent from org.joda.time.DateTimeConstants
275+
* @param calendarDayOfWeek day of the week constant from java.util.Calendar
276+
* @return day of the week constant equivalent from org.joda.time.DateTimeConstants
277277
*/
278-
private int convertCalendarWeekdayToJoda(int calendarWeekday) {
278+
private int convertCalendarDayOfWeekToJoda(int calendarDayOfWeek) {
279279
Calendar cal = Calendar.getInstance();
280-
cal.set(Calendar.DAY_OF_WEEK, calendarWeekday);
280+
cal.set(Calendar.DAY_OF_WEEK, calendarDayOfWeek);
281281
return LocalDateTime.fromCalendarFields(cal).getDayOfWeek();
282282
}
283283

app/src/test/java/org/gnucash/android/test/unit/model/ScheduledActionTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ public void testComputingTimeOfLastSchedule(){
136136
}
137137

138138
/**
139-
* Weekly actions scheduled to run on multiple weekdays should be due
139+
* Weekly actions scheduled to run on multiple days of the week should be due
140140
* in each of them in the same week.
141141
*
142142
* For an action scheduled on Mondays and Thursdays, we test that, if
143143
* the last run was on Monday, the next should be due on the Thursday
144144
* of the same week instead of the following week.
145145
*/
146146
@Test
147-
public void multiWeekdayWeeklyActions_shouldBeDueOnEachWeekdaySet() {
147+
public void multiDayOfWeekWeeklyActions_shouldBeDueOnEachDayOfWeekSet() {
148148
ScheduledAction scheduledAction = new ScheduledAction(ScheduledAction.ActionType.BACKUP);
149149
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
150150
recurrence.setByDays(Arrays.asList(Calendar.MONDAY, Calendar.THURSDAY));
@@ -159,10 +159,10 @@ public void multiWeekdayWeeklyActions_shouldBeDueOnEachWeekdaySet() {
159159

160160
/**
161161
* Weekly actions scheduled with multiplier should skip intermediate
162-
* weeks and be due in the specified weekday.
162+
* weeks and be due in the specified day of the week.
163163
*/
164164
@Test
165-
public void weeklyActionsWithMultiplier_shouldBeDueOnTheWeekdaySet() {
165+
public void weeklyActionsWithMultiplier_shouldBeDueOnTheDayOfWeekSet() {
166166
ScheduledAction scheduledAction = new ScheduledAction(ScheduledAction.ActionType.BACKUP);
167167
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
168168
recurrence.setMultiplier(2);
@@ -179,12 +179,12 @@ public void weeklyActionsWithMultiplier_shouldBeDueOnTheWeekdaySet() {
179179

180180
/**
181181
* Weekly actions should return a date in the future when no
182-
* weekdays have been set in the recurrence.
182+
* days of the week have been set in the recurrence.
183183
*
184184
* See ScheduledAction.computeNextTimeBasedScheduledExecutionTime()
185185
*/
186186
@Test
187-
public void weeklyActionsWithoutWeekdaySet_shouldReturnDateInTheFuture() {
187+
public void weeklyActionsWithoutDayOfWeekSet_shouldReturnDateInTheFuture() {
188188
ScheduledAction scheduledAction = new ScheduledAction(ScheduledAction.ActionType.BACKUP);
189189
Recurrence recurrence = new Recurrence(PeriodType.WEEK);
190190
recurrence.setByDays(Collections.<Integer>emptyList());

0 commit comments

Comments
 (0)