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

未关闭
#31,600 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
3 天 4 小时
30 天内合并 PR
72

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/ionic-framework 的其他 Issue

查看 ionic-team/ionic-framework 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。