Problem/Motivation
When the site's/user's time zone is UTC, the widget works as expected. However, with time zones behind UTC (e.g. New York or Honolulu), it does not. When the user selects a date, the date field sets itself to the day before the selected one.
Steps to reproduce
- Basic setup:
- Set up a fresh Drupal 9 site with facets_date_range enabled.
- Set up a content type with a date field (date only, no time).
- Create a few nodes with different dates.
- Set up a database search server, search index, and view of the search index with a page display.
- Set up a facet for the date field, with the Date Range Picker widget and facet setting selected.
- Add the facet block to the search page.
- Key steps to reproduce the bug:
- In Configuration > Regional Settings, change the default time zone to Honolulu. Uncheck "Users may set their own time zone".
- On the search page, use the facet's calendar widget to select a date, e.g. 2022.03.30.
The URL shows the timestamp for the expected date, e.g. 1648598400 = 2022.03.30 00:00:00 +0000. But the date field shows the wrong date, e.g. 2022.03.29.
Proposed resolution
When the code converts between dates and timestamps, consistently use UTC. (I'll submit a merge request shortly.)
Issue fork facets_date_range-3272572
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jlstreckerComment #4
jlstreckerComment #5
jhedstromThis resolves an issue I was seeing on a site with a non-UTC timezone.
Comment #8
claudiu.cristeaMerged. Thank you!
Comment #9
claudiu.cristea