Fix: DatePickerInput sends date-only strings instead of ISO datetime with timezone#2835
Fix: DatePickerInput sends date-only strings instead of ISO datetime with timezone#2835Allaoua9 wants to merge 1 commit intoChainlit:mainfrom
Conversation
|
This PR is stale because it has been open for 14 days with no activity. |
|
This PR was closed because it has been inactive for 7 days since being marked as stale. |
hayescode
left a comment
There was a problem hiding this comment.
Please keep the new date-only write format, but make the read path backward-compatible with legacy ISO timestamp values and add a targeted regression test for both formats.
| try { | ||
| const date = new Date(dateStr); | ||
| // Append T00:00:00 to force local timezone parsing instead of UTC | ||
| const date = new Date(dateStr + 'T00:00:00'); |
There was a problem hiding this comment.
This needs to stay backward-compatible with existing values. Appending T00:00:00 unconditionally breaks previously emitted ISO timestamp-shaped values like 2025-11-26T00:00:00.000Z. Please keep parsing tolerant of both legacy ISO timestamps and the new date-only format.
| return date.toISOString(); | ||
| const year = date.getFullYear(); | ||
| const month = String(date.getMonth() + 1).padStart(2, '0'); | ||
| const day = String(date.getDate()).padStart(2, '0'); |
There was a problem hiding this comment.
Writing YYYY-MM-DD looks fine to me, but before we merge this we should add coverage proving both old persisted values and the new date-only values round-trip correctly.
The DatePickerInput component was sending full ISO 8601 datetime strings (e.g. 2025-11-26T00:00:00.000Z) to the backend. For date-only fields, this could cause off-by-one day errors when the UTC conversion shifted the date.
Summary by cubic
DatePickerInput now sends date-only strings (YYYY-MM-DD) instead of ISO datetimes with timezone to prevent off-by-one day shifts in UTC.
formatDateValuenow outputsYYYY-MM-DDinstead oftoISOString().parseDateappendsT00:00:00to force local timezone parsing and avoid UTC conversion.Written for commit fbdee38. Summary will update on new commits.