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.)

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jlstrecker created an issue. See original summary.

jlstrecker’s picture

Status: Active » Needs review
jlstrecker’s picture

Assigned: jlstrecker » Unassigned
jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

This resolves an issue I was seeing on a site with a non-UTC timezone.

claudiu.cristea made their first commit to this issue’s fork.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thank you!

claudiu.cristea’s picture

Version: 1.0.0-beta1 » 1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.