Update widgets at midnight (#634)

This commit is contained in:
Kristian Tashkov
2020-09-06 01:25:46 +03:00
committed by Alinson S. Xavier
parent 2cf3347f8c
commit 4dd77463fb
8 changed files with 51 additions and 8 deletions

View File

@@ -164,6 +164,8 @@ public class ReminderScheduler implements CommandRunner.Listener
{
void scheduleShowReminder(long reminderTime, Habit habit, long timestamp);
void scheduleWidgetUpdate(long updateTime);
void log(String componentName, String msg);
}
}

View File

@@ -175,9 +175,14 @@ public abstract class DateUtils
return getStartOfDay(getLocalTime());
}
public static long getStartOfTomorrow()
{
return getUpcomingTimeInMillis(0, 0);
}
public static long millisecondsUntilTomorrow()
{
return getStartOfToday() + DAY_LENGTH - getLocalTime();
return getStartOfTomorrow() - getLocalTime();
}
public static GregorianCalendar getStartOfTodayCalendar()

View File

@@ -164,6 +164,7 @@ public class DateUtilsTest extends BaseUnitTest
@Test
public void testMillisecondsUntilTomorrow() throws Exception
{
DateUtils.setFixedTimeZone(TimeZone.getTimeZone("GMT"));
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 1, 23, 59));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(60000L));