Change start of tomorrow to also use with offset name

pull/621/head
KristianTashkov 5 years ago
parent d7602581d3
commit c5a04d9e79

@ -64,7 +64,7 @@ class WidgetUpdater
}
fun scheduleStartDayWidgetUpdate() {
val timestamp = DateUtils.getStartOfTomorrow()
val timestamp = DateUtils.getStartOfTomorrowWithOffset()
intentScheduler.scheduleWidgetUpdate(timestamp);
}

@ -202,19 +202,19 @@ public abstract class DateUtils
return getStartOfDay(getLocalTime());
}
public static long getStartOfTomorrow()
public static long getStartOfTomorrowWithOffset()
{
return getUpcomingTimeInMillis(startDayHourOffset, startDayMinuteOffset);
}
public static long getStartOfTodayWithOffset()
{
return getStartOfDayWithOffset(getLocalTime());
}
public static long millisecondsUntilTomorrow()
public static long millisecondsUntilTomorrowWithOffset()
{
return getStartOfTomorrow() - getLocalTime();
return getStartOfTomorrowWithOffset() - getLocalTime();
}
public static GregorianCalendar getStartOfTodayCalendar()

@ -56,7 +56,7 @@ public class MidnightTimer
{
executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleAtFixedRate(() -> notifyListeners(),
DateUtils.millisecondsUntilTomorrow() + 1000,
DateUtils.millisecondsUntilTomorrowWithOffset() + 1000,
DateUtils.DAY_LENGTH, TimeUnit.MILLISECONDS);
}

@ -166,17 +166,17 @@ public class DateUtilsTest extends BaseUnitTest
DateUtils.setFixedTimeZone(TimeZone.getTimeZone("GMT"));
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 1, 23, 59));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(MINUTE_LENGTH));
assertThat(DateUtils.millisecondsUntilTomorrowWithOffset(), equalTo(MINUTE_LENGTH));
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 1, 20, 0));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(4 * HOUR_LENGTH));
assertThat(DateUtils.millisecondsUntilTomorrowWithOffset(), equalTo(4 * HOUR_LENGTH));
DateUtils.setStartDayOffset(3, 30);
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 1, 23, 59));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(3 * HOUR_LENGTH + 31 * MINUTE_LENGTH));
assertThat(DateUtils.millisecondsUntilTomorrowWithOffset(), equalTo(3 * HOUR_LENGTH + 31 * MINUTE_LENGTH));
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 2, 1, 0));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(2 * HOUR_LENGTH + 30 * MINUTE_LENGTH));
assertThat(DateUtils.millisecondsUntilTomorrowWithOffset(), equalTo(2 * HOUR_LENGTH + 30 * MINUTE_LENGTH));
}
@Test

Loading…
Cancel
Save