Skip to content

Fix: DatePickerInput sends date-only strings instead of ISO datetime with timezone#2835

Open
Allaoua9 wants to merge 1 commit intoChainlit:mainfrom
Allaoua9:fix/invalid-date-utc
Open

Fix: DatePickerInput sends date-only strings instead of ISO datetime with timezone#2835
Allaoua9 wants to merge 1 commit intoChainlit:mainfrom
Allaoua9:fix/invalid-date-utc

Conversation

@Allaoua9
Copy link
Copy Markdown
Contributor

@Allaoua9 Allaoua9 commented Mar 9, 2026

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.

  • Bug Fixes
    • formatDateValue now outputs YYYY-MM-DD instead of toISOString().
    • parseDate appends T00:00:00 to force local timezone parsing and avoid UTC conversion.

Written for commit fbdee38. Summary will update on new commits.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. frontend Pertains to the frontend. labels Mar 9, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Mar 24, 2026
@github-actions
Copy link
Copy Markdown

This PR was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this Mar 31, 2026
@hayescode hayescode reopened this Mar 31, 2026
@github-actions github-actions bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 1, 2026
Copy link
Copy Markdown
Contributor

@hayescode hayescode left a comment

Choose a reason for hiding this comment

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

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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Pertains to the frontend. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants