Search criteria: relative date

This commit is contained in:
M66B 2022-03-18 19:46:23 +01:00
parent 9d5eb77899
commit 9e1eee0420
2 changed files with 22 additions and 4 deletions

View File

@ -51,6 +51,7 @@ import java.nio.charset.StandardCharsets;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -1095,11 +1096,17 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
json.put("in_trash", in_trash);
json.put("in_junk", in_junk);
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MINUTE, 0);
now.set(Calendar.HOUR, 0);
if (after != null)
json.put("after", after);
json.put("after", after - now.getTimeInMillis());
if (before != null)
json.put("before", before);
json.put("before", before - now.getTimeInMillis());
return json;
}
@ -1135,11 +1142,17 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
criteria.in_trash = json.optBoolean("in_trash");
criteria.in_junk = json.optBoolean("in_junk");
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
now.set(Calendar.SECOND, 0);
now.set(Calendar.MINUTE, 0);
now.set(Calendar.HOUR, 0);
if (json.has("after"))
criteria.after = json.getLong("after");
criteria.after = json.getLong("after") + now.getTimeInMillis();
if (json.has("before"))
criteria.before = json.getLong("before");
criteria.before = json.getLong("before" + now.getTimeInMillis());
return criteria;
}

View File

@ -591,6 +591,11 @@ public class FragmentDialogSearch extends FragmentDialogBase {
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
cal.set(Calendar.MILLISECOND, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);