Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly highlight selected day in date picker. (5.1) #17121

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

linuspahl
Copy link
Contributor

@linuspahl linuspahl commented Oct 30, 2023

Please note, this PR is a backport of #16973 for 5.1.

Description

Motivation and Context

As described in #16096 the highlight for the selected date in the date picker can be wrong for a date time like 2023-10-17 00:00:00. In this case it displayed the previous day as active.

The reason is that the date time does not contain a time zone information and moment() still uses the estimated user time zone internally. For example when your browser timezone is Europe/Paris the UTC time for 2023-10-17 00:00:00 is 2023-10-16 22:00:00.

We are now:

  • using moment.utc() instead of moment() to make it's behaviour predictable for date times without a time zone.
    This only effects few cases, because usually timestamps in the frontend have a timezone.
  • considering the user time zone when handling dates in the date picker.

There are more improvements we can make regarding the date time utils, but I will do them in a follow-up PR, so this PR will be easy to backport.

Fixes: #16096
Fixes: https://github.com/Graylog2/graylog-plugin-enterprise/issues/5998

* Consider user timezone when displaying indicator for active date in date picker.

* Use moment.utc for date time utils to make them predictable.

* Fix linter hint

* Adding changelog.

* Updating tests.

* Define time zone provided for calendar in search date picker.

* Adding test

* Updating prop types.

* Fix typo.
@linuspahl linuspahl marked this pull request as ready for review October 31, 2023 08:52
@linuspahl linuspahl merged commit 309c7c6 into 5.1 Oct 31, 2023
3 checks passed
@linuspahl linuspahl deleted the issue-16096/date-time-picker-5.1 branch October 31, 2023 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants