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. #16973

Merged
merged 9 commits into from
Oct 30, 2023

Conversation

linuspahl
Copy link
Contributor

@linuspahl linuspahl commented Oct 18, 2023

Please note, this PR needs a backport for 5.0 and 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

@linuspahl linuspahl force-pushed the issue-16096/date-time-picker branch from 7f85fbd to b2e6c0f Compare October 19, 2023 06:45
@linuspahl linuspahl marked this pull request as ready for review October 19, 2023 09:03
Copy link
Contributor

@ousmaneo ousmaneo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works. Thank you for this fix.

@linuspahl linuspahl force-pushed the issue-16096/date-time-picker branch from db8f68a to 9d5ea4e Compare October 30, 2023 14:00
@linuspahl linuspahl merged commit b383be0 into master Oct 30, 2023
2 checks passed
@linuspahl linuspahl deleted the issue-16096/date-time-picker branch October 30, 2023 17:11
linuspahl added a commit that referenced this pull request Oct 30, 2023
* 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 added a commit that referenced this pull request Oct 30, 2023
* 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 added a commit that referenced this pull request Oct 31, 2023
* 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 added a commit that referenced this pull request Oct 31, 2023
* 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 added a commit that referenced this pull request Oct 31, 2023
* 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.
dennisoelkers pushed a commit that referenced this pull request Nov 13, 2023
* 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.
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.

Absolute Datetime picker jump to previous day when we click on beginning of the day
3 participants