fix: use system timezone in gr.DateTime with include_time=False #9825
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When using
gr.DateTime
withinclude_time=False
, the frontend code creates a newDate
object out of the chosen date string.There is a discrepancy in the way date-only and date-time strings are dealt with in JS by the
Date
constructor, which causes the date string to be interpreted as if it specified a time in the UTC timezone (source):Due to this behavior, if the user's system timezone is one which has a negative offset with respect to UTC, the date returned by a
gr.DateTime
component withinclude_time=False
would correspond to the day preceding the one selected by the user, which is wrong.By appending
"T00:00:00"
, we turn the date-only string into a date-time string, which will be parsed correctly as per the user's system timezone (not necessarily UTC).Closes: #9573