Make date filter inclusive

Created on 20 February 2023, over 1 year ago
Updated 19 March 2023, over 1 year ago

Problem/Motivation

When users see "start" and "end" date filters on a View, they think that if they want to see results from March 1, they should enter March 1 for both the start and end dates, but the date filter evaluates these as the same instant instead of 24 hours apart.

Steps to reproduce

Create content with a date value during a certain date (say, noon on March 1) and index it. Search for that content using a date filter set to start and end on that date. The content will not appear because noon on March 1 is not between midnight and midnight on March 1. Now set the end date to March 2, and the content will be found.

Proposed resolution

A patch being developed for the core Views date filter at https://drupal.org/node/2982968 works very nicely to add a day to the max filter if it it submitted without a ":" character. However, this fix is in the getConvertedValues() method of the date filter object, and Search API's extension of the object does not call that method. Perhaps it would be better for compatibility to call the parent method, but I don't fully understand why the decision was made not to use it, so instead I will just add the code into the opBetween() method.

Remaining tasks

submit a patch.

✨ Feature request
Status

Fixed

Version

1.0

Component

Views integration

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024