Skip to content

fix(datetime): emit date-only value for presentations without a time picker - #31808

Open
Goldloli wants to merge 1 commit into
ionic-team:nextfrom
Goldloli:fix/datetime-date-only-default-value
Open

Goldloli wants to merge 1 commit into
ionic-team:nextfrom
Goldloli:fix/datetime-date-only-default-value

Conversation

@Goldloli

@Goldloli Goldloli commented Nov 23, 2026 •

Copy link
Copy Markdown

Issue number: resolves #31600


What is the current behavior?

Confirming a selection in <ion-datetime presentation="date"> with no initial value emits a full timestamp such as 2026-09-01T16:19:00, where the time is whatever the device clock showed when the component initialised.

This happens because defaultParts is derived from parseDate(getToday()), which carries hour/minute, and convertDataToISO() appends T${hour}:${minute}:00 whenever hour !== undefined, regardless of the presentation.

What is the new behavior?

  • The default parts no longer carry the time fields (hour, minute, ampm) for presentations that do not render a time picker (date, month, year, month-year).
  • Confirming a selection with no initial value now emits YYYY-MM-DD for those presentations, matching the format already emitted today when a date-only value is passed (the round-trip behavior confirmed in the issue).
  • time, date-time, and time-date are unchanged.
  • A removeTimeParts helper was added to utils/manipulation.ts and applied where defaultParts is computed in datetime.tsx.

Does this introduce a breaking change?

  • Yes

Applications that relied on the time portion of values emitted by date, month, year, or month-year presentations without an initial value will now receive a date-only string. This aligns with the note in #31600 that changing what an empty datetime returns is a behavioral change tracked for a major release, so this PR targets next and updates BREAKING.md accordingly. Applications that need the time portion should use the date-time or time-date presentations.

Other information

  • A/B verification: on next without this change, the new test receives 2026-10-10T01:42:00 (the local clock at run time); with this change it receives 2026-10-10.
  • npx stencil test --spec --max-workers=2 src/components/datetime: 10 suites, 124 tests passed.
  • npx playwright test src/components/datetime/test/basic/datetime.e2e.ts (Mobile Chrome + Mobile Safari projects): 153 passed, 1 skipped, including two new tests covering the date-only emission and a date-time guard test asserting the full timestamp is preserved. The Mobile Firefox project could not be launched on this machine (local Playwright Firefox install issue, unrelated to this change) and is covered by CI.
  • Note on screenshot tests: the committed baselines in this repo are generated in Docker on Linux, so on this macOS machine Playwright wrote local darwin baselines for the screenshot tests rather than comparing against the committed ones. The change only removes time fields from the default parts and the full existing spec suite above passes, but visual verification against the committed baselines is left to CI.

…picker

Confirming a selection with no initial value emitted a full timestamp
(e.g. 2026-09-01T16:19:00) where the time was the device clock when
the component loaded. The default parts now drop the time fields for
presentations that do not render a time picker, so the emitted value
matches the date-only format already used when a date-only value is
passed.

BREAKING CHANGE: ion-datetime now emits date-only values for the
date, month, year, and month-year presentations when confirming a
selection without an initial value. Applications relying on the time
portion should use the date-time or time-date presentations.
@Goldloli
Goldloli requested a review from a team as a code owner November 23, 2026 17:52
@Goldloli
Goldloli requested a review from thetaPC November 23, 2026 17:52
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Goldloli is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Nov 23, 2026

This branch has not been deployed

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

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant