Skip to content

Conversation

yihuiliao
Copy link
Member

@yihuiliao yihuiliao commented Oct 21, 2025

Closes #9064

should be fine to get rid of the timezone since this only updates the value passed to the hidden date input and won't be submitted to a form. since neither input type="date" or input type="datetime-local" support timezones, it makes sense to remove it.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Go to the RAC DateField Autofill and DatePicker Autofill story. Check the browser to make sure there aren't any console warnings. If autofill is supported (so far have only gotten it to work in Safari), clear the date in the field and try autofilling with your contact info.

🧢 Your Project:

@rspbot
Copy link

rspbot commented Oct 21, 2025

@yihuiliao yihuiliao marked this pull request as ready for review October 21, 2025 19:04
let dateValue = state.value == null ? '' : state.value.toString();
let dateValue = '';
if (state.value != null && 'toAbsoluteString' in state.value) {
dateValue = state.value.toAbsoluteString().replace('Z', '');
Copy link
Member

Choose a reason for hiding this comment

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

there will never be something after the Z?

Copy link
Member Author

@yihuiliao yihuiliao Oct 21, 2025

Choose a reason for hiding this comment

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

yeah there shouldn't. toAbsoluteString makes use of .toISOString() which formats the date as the following YYYY-MM-DDTHH:mm:ss.sssZ. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

/** Converts the date to an ISO 8601 formatted string in UTC. */
toAbsoluteString(): string {
return this.toDate().toISOString();
}

Copy link
Member

@devongovett devongovett Oct 22, 2025

Choose a reason for hiding this comment

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

I think toAbsoluteString would not quite be right, because it returns the date in UTC whereas datetime-local expects it to be in the user's local time zone.

Also for granularity="day", the value may still be a CalendarDateTime or ZonedDateTime, we only display the date. Formatting it as a string will produce a full date time where the browser will expect only a date.

Maybe what we should do is always convert it to a CalendarDate or CalendarDateTime before converting to a string, depending on the granularity.

dateValue = state.granularity === 'day' 
  ? toCalendarDate(state.value).toString() 
  : toCalendarDateTime('timeZone' in state.value ? toLocalTimeZone(state.value) : state.value).toString()

snowystinger
snowystinger previously approved these changes Oct 21, 2025
@rspbot
Copy link

rspbot commented Oct 22, 2025

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.

react-aria-components: Console warning occurs when DatePicker is used with ZonedDateTime

4 participants