fix TriggerRecurringTime #2
This commit is contained in:
parent
1cb648c09a
commit
0a33f4c0db
3 changed files with 8 additions and 7 deletions
|
@ -34,8 +34,8 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun() : Boolean {
|
||||||
val currentMinSinceMidnight = getMinSinceMidnight(DateUtil.now())
|
val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now())
|
||||||
val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK]
|
val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK]
|
||||||
if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) {
|
if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) {
|
||||||
if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) {
|
if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) {
|
||||||
|
|
|
@ -17,11 +17,7 @@ class TriggerRecurringTimeTest : TriggerTestBase() {
|
||||||
var now = 1514766900000L // 95 min from midnight
|
var now = 1514766900000L // 95 min from midnight
|
||||||
|
|
||||||
@Before fun mock() {
|
@Before fun mock() {
|
||||||
PowerMockito.mockStatic(DateUtil::class.java)
|
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
|
||||||
PowerMockito.`when`(DateUtil.now()).thenReturn(now)
|
|
||||||
// val calendar = GregorianCalendar()
|
|
||||||
// calendar.timeInMillis = now
|
|
||||||
// PowerMockito.`when`(DateUtil.gregorianCalendar()).thenReturn(calendar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun shouldRunTest() {
|
@Test fun shouldRunTest() {
|
||||||
|
|
|
@ -261,6 +261,10 @@ public class DateUtil {
|
||||||
return timeFrameString(timestamp - System.currentTimeMillis(), resourceHelper);
|
return timeFrameString(timestamp - System.currentTimeMillis(), resourceHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long _now() {
|
||||||
|
return System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
public static long now() {
|
public static long now() {
|
||||||
return System.currentTimeMillis();
|
return System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
@ -358,6 +362,7 @@ public class DateUtil {
|
||||||
// singletons to avoid repeated allocation
|
// singletons to avoid repeated allocation
|
||||||
private static DecimalFormatSymbols dfs;
|
private static DecimalFormatSymbols dfs;
|
||||||
private static DecimalFormat df;
|
private static DecimalFormat df;
|
||||||
|
|
||||||
public static String qs(double x, int digits) {
|
public static String qs(double x, int digits) {
|
||||||
|
|
||||||
if (digits == -1) {
|
if (digits == -1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue