diff --git a/astrid/src/com/todoroo/astrid/helper/DueDateTimeMigrator.java b/astrid/src/com/todoroo/astrid/helper/DueDateTimeMigrator.java index df1d694e1..79dd437dc 100644 --- a/astrid/src/com/todoroo/astrid/helper/DueDateTimeMigrator.java +++ b/astrid/src/com/todoroo/astrid/helper/DueDateTimeMigrator.java @@ -36,13 +36,28 @@ public class DueDateTimeMigrator { TodorooCursor tasksWithDueTime = taskDao.query(Query.select(Task.ID, Task.TITLE, Task.DUE_DATE).where( Criterion.and(Task.DUE_DATE.gt(0), Criterion.not(Functions.strftime(Task.DUE_DATE, STRFTIME_FORMAT).eq(LEGACY_NO_TIME_STRING))))); + try { - // Get tasks with no due time (i.e. due date = 23:59:59) - TodorooCursor tasksWithoutDueTime = taskDao.query(Query.select(Task.ID, Task.TITLE, Task.DUE_DATE).where( - Criterion.and(Task.DUE_DATE.gt(0), - Functions.strftime(Task.DUE_DATE, STRFTIME_FORMAT).eq(LEGACY_NO_TIME_STRING)))); + // Get tasks with no due time (i.e. due date = 23:59:59) + TodorooCursor tasksWithoutDueTime = taskDao.query(Query.select(Task.ID, Task.TITLE, Task.DUE_DATE).where( + Criterion.and(Task.DUE_DATE.gt(0), + Functions.strftime(Task.DUE_DATE, STRFTIME_FORMAT).eq(LEGACY_NO_TIME_STRING)))); + + try { + // Set tasks without time to 12:00:00 + processCursor(tasksWithoutDueTime, new TaskDateAdjuster() { + @Override + public void adjust(Date date) { + date.setHours(12); + date.setMinutes(0); + date.setSeconds(0); + } + }); + + } finally { + tasksWithoutDueTime.close(); + } - try { // Set tasks with time to have time HH:MM:01 processCursor(tasksWithDueTime, new TaskDateAdjuster() { @Override @@ -51,19 +66,10 @@ public class DueDateTimeMigrator { } }); - // Set tasks without time to 12:00:00 - processCursor(tasksWithoutDueTime, new TaskDateAdjuster() { - @Override - public void adjust(Date date) { - date.setHours(12); - date.setMinutes(0); - date.setSeconds(0); - } - }); } finally { tasksWithDueTime.close(); - tasksWithoutDueTime.close(); } + Preferences.setBoolean(PREF_MIGRATED_DUE_TIMES, true); } }