Set last reminder to end of minute

pull/574/head
Alex Baker 7 years ago
parent 1ade6ea447
commit 1fe75899b6

@ -327,4 +327,11 @@ public class DateTimeTest {
new DateTime(2017, 9, 3, 0, 51, 0, 0),
new DateTime(2017, 9, 3, 0, 51, 13, 427).startOfMinute());
}
@Test
public void testEndOfMinute() {
assertEquals(
new DateTime(2017, 9, 22, 14, 47, 59, 999),
new DateTime(2017, 9, 22, 14, 47, 14, 453).endOfMinute());
}
}

@ -31,6 +31,7 @@ import org.tasks.reminders.NotificationActivity;
import org.tasks.reminders.SnoozeActivity;
import org.tasks.reminders.SnoozeDialog;
import org.tasks.reminders.SnoozeOption;
import org.tasks.time.DateTime;
import org.tasks.ui.CheckBoxes;
import java.util.ArrayList;
@ -318,7 +319,7 @@ public class NotificationManager {
final String taskDescription = task.getNotes();
// update last reminder time
task.setReminderLast(when);
task.setReminderLast(new DateTime(when).endOfMinute().getMillis());
taskDao.saveExisting(task);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationManager.NOTIFICATION_CHANNEL_DEFAULT)

@ -85,6 +85,13 @@ public class DateTime {
return new DateTime(calendar);
}
public DateTime endOfMinute() {
Calendar calendar = getCalendar();
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
return new DateTime(calendar);
}
public DateTime withMillisOfDay(int millisOfDay) {
if (millisOfDay > MAX_MILLIS_PER_DAY || millisOfDay < 0) {
throw new RuntimeException("Illegal millis of day: " + millisOfDay);

Loading…
Cancel
Save