Skip to content

Commit

Permalink
Change calculation to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Mar 4, 2024
1 parent e5c2640 commit ecfe0af
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/src/org/commcare/utils/SyncDetailCalculations.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@ private static boolean unsentFormNumberLimitExceeded(int numUnsentForms) {
private static boolean unsentFormTimeLimitExceeded(long lastSyncTime) {
SharedPreferences prefs = CommCareApplication.instance().getCurrentApp().getAppPreferences();
double unsentFormTimeLimitInDays = Double.parseDouble(prefs.getString(UNSENT_FORM_TIME_KEY, "5"));
int unsentFormTimeLimitInMinutes = (int)(unsentFormTimeLimitInDays * 24 * 60);
long unsentFormTimeLimitInMsecs = (int)(unsentFormTimeLimitInDays * 24 * 60 * 60 * 1000);

long now = new Date().getTime();
int secsSinceLastSync = (int)((now - lastSyncTime) / 1000);
int minutesSinceLastSync = (int)(secsSinceLastSync / 60);
long msecsSinceLastSync = (now - lastSyncTime);

return minutesSinceLastSync > unsentFormTimeLimitInMinutes;
return msecsSinceLastSync > unsentFormTimeLimitInMsecs;
}
}

0 comments on commit ecfe0af

Please sign in to comment.