-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
bugissue that does not match design or documentation and requires code changes to addressissue that does not match design or documentation and requires code changes to addresshacktoberfestPRs submitted in October (open-source celebration month)PRs submitted in October (open-source celebration month)
Description
Expected Behavior
When defaultValue has no timezone, everything is returned without a timezone and is assumed to be local time. The value in state, input, and active calendar date should all display the same value.
Actual Behavior
The value in state is not in sync with input and active calendar date.
This is a similar issue to what is reported by #6356.
The fix provided in #6396 should be applied in a few other locations:
adjustedDate.setHours(hour, offset); adjustedDate.setHours(hour, offset); - And possibly:
result.setHours(result.getHours() - hourDelta);
Since this logic is duplicated in multiple locations, consider moving to a single util function.
const adjustedDate = new Date(dateValue);
// if time is not specified in ISOstring, normalize to midnight
if (dateValue.indexOf('T') === -1) {
const offset = adjustedDate.getTimezoneOffset();
const hour = adjustedDate.getHours();
adjustedDate.setHours(hour, offset < 0 ? -offset : offset);
}
result = adjustedDate;
URL, screen shot, or Codepen exhibiting the issue
Steps to Reproduce
- Use this story: https://storybook.grommet.io/?path=/story/input-dateinput-format-inline--format-inline
- Specifically scenarios 3 & 5
- Set OS timezone to IST.
Your Environment
- Grommet version: 2.27.0
- Browser Name and version: all
- Operating System and version (desktop or mobile): MacOS 12.6
Metadata
Metadata
Assignees
Labels
bugissue that does not match design or documentation and requires code changes to addressissue that does not match design or documentation and requires code changes to addresshacktoberfestPRs submitted in October (open-source celebration month)PRs submitted in October (open-source celebration month)