bug: ion-datetime presentation="date" emits `YYYY-MM-DDTHH:mm:00` (the current wall-clock time) instead of a date-only value

Offen
#31,600 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
frontend

Rechercherichtung

Start in core/src/components/datetime/datetime.tsx and trace how todayParts and defaultParts feed the selected date; then inspect convertDataToISO in utils/manipulation.ts. Check the date-only behavior against the documented presentation="date" format and run the relevant datetime tests. Done means selecting a day emits YYYY-MM-DD without a time.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

package: core type: bug
Ionic Framework Version

v9.x (9.0.7)

Current Behavior

<ion-datetime presentation="date"> with no initial value: clicking a day emits

ionChange detail.value = "2026-09-01T16:19:00"

at 16:19 local time, and datetime.value reads the same string. The time part is whatever the clock showed when the component initialised.

Where it comes from (core/src/components/datetime/datetime.tsx):

  • L1529 this.todayParts = parseDate(getToday()) — getToday() (utils/data.ts L27–46) returns a full ISO timestamp, so the parts carry hour/minute;
  • L1534 defaultParts is derived from them, and selecting a day keeps those hour/minute fields;
  • convertDataToISO (utils/manipulation.ts L37–40) appends T${hour}:${minute}:00 whenever hour !== undefined, regardless of presentation.

A backend DateOnly / date column rejects the value, and the same picker opened on two days produces two different strings for the same date.

Expected Behavior

presentation="date" emits YYYY-MM-DD (the format the docs describe for a date-only picker and the one min/max accept).

Steps to Reproduce
  1. <ion-datetime presentation="date"></ion-datetime> with no value.
  2. Click any enabled day.
  3. Read event.detail.value in ionChange.
Ionic Info

@ionic/core 9.0.7, Chromium 142 (Playwright headless).

Vorherrschende Sprache
TypeScript
Sterne
52.7k
Forks
13.3k
Ø Merge
3 T. 4 Std.
Gemergte PRs (30 T.)
72

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ionic-team/ionic-framework

Alle Issues in ionic-team/ionic-framework

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.