Skip to content

Commit bd4348a

Browse files
committed
Started building better monthly repeat logic
1 parent 87796e9 commit bd4348a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

api/src/com/todoroo/andlib/utility/DateUtilities.java

+15
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,21 @@ public static String getRelativeDay(Context context, long date, boolean abbrevia
247247
return DateUtilities.getDateStringHideYear(context, new Date(date));
248248
}
249249

250+
public static boolean isEndOfMonth(Date d) {
251+
int date = d.getDate();
252+
if (date < 28)
253+
return false;
254+
255+
int month = d.getMonth();
256+
if (month == Calendar.FEBRUARY)
257+
return date >= 28;
258+
259+
if (month == Calendar.APRIL || month == Calendar.JUNE || month == Calendar.SEPTEMBER || month == Calendar.NOVEMBER)
260+
return date >= 30;
261+
262+
return date >= 31;
263+
}
264+
250265
/**
251266
* Calls getRelativeDay with abbreviated parameter defaulted to true
252267
*/

astrid/plugin-src/com/todoroo/astrid/repeats/RepeatTaskCompleteListener.java

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public static long computeNextDueDate(Task task, String recurrence, boolean repe
127127
return handleSubdayRepeat(original, rrule);
128128
else if(rrule.getFreq() == Frequency.WEEKLY && rrule.getByDay().size() > 0 && repeatAfterCompletion)
129129
return handleWeeklyRepeatAfterComplete(rrule, original, task.hasDueTime());
130+
else if (rrule.getFreq() == Frequency.MONTHLY)
131+
return handleMonthlyRepeat(original, startDateAsDV, rrule);
130132
else
131133
return invokeRecurrence(rrule, original, startDateAsDV);
132134
}
@@ -153,6 +155,11 @@ private static long handleWeeklyRepeatAfterComplete(RRule rrule, Date original,
153155
return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, time);
154156
}
155157

158+
private static long handleMonthlyRepeat(Date original, DateValue startDateAsDV, RRule rrule) {
159+
//
160+
return invokeRecurrence(rrule, original, startDateAsDV);
161+
}
162+
156163
private static Comparator<WeekdayNum> weekdayCompare = new Comparator<WeekdayNum>() {
157164
@Override
158165
public int compare(WeekdayNum object1, WeekdayNum object2) {

0 commit comments

Comments
 (0)