Skip to content

Commit

Permalink
Form filter - Date range: add a day to the max values when requesting…
Browse files Browse the repository at this point in the history
… data
  • Loading branch information
mdouchin committed Oct 25, 2023
1 parent 7d13010 commit a0a31ec
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion assets/src/legacy/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,16 @@ var lizLayerFilterTool = function () {

// max date filter
if (max_val && Date.parse(max_val)) {
filters.push('( "' + startField + '"' + " <= '" + max_val + "'" + " OR " + ' "' + endField + '"' + " <= '" + max_val + "' )");
// Add one day to the max values as we cannot select hours
// This allow to select features with the max value. Eg a feature with 2023-10-25 12:20:01
// must be selected if max date is 2023-10-25 wich is indeed 2023-10-25 00:00:00
let max_val_new = new Date(Date.parse(max_val));
// Add a day
max_val_new.setDate(max_val_new.getDate() + 1);
// Truncate to keep only date & transform into string
let max_val_new_str = formatDT(max_val_new, 'yy-mm-dd');
// We use strict < instead of <= because we just add a day to the max value
filters.push('( "' + startField + '"' + " < '" + max_val_new_str + "'" + " OR " + ' "' + endField + '"' + " < '" + max_val_new_str + "' )");
} else {
max_val = null;
}
Expand Down

0 comments on commit a0a31ec

Please sign in to comment.