mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Update widgets at midnight (#634)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user