Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@web-97
Copy link
Contributor

@web-97 web-97 commented Jun 4, 2025

What

当table配置了
{ "quickEdit": { "type": "date-range" }, "name": "time", "label": "日期", "type": "date" }
快捷编辑时间范围
这时候Date组件便会收到如1744041600,1749139199
点击确认会显示
image
image
1744-04-16
这很神奇?

Why

因为Date组件调用normalizeDate->moment('1744041600,1749139199','YYYY-MM-DD HH:mm:ss')
神奇的事情发生了
moment尝试把17440416..转换为YYYY-MM-DD HH:mm:ss 是成功的isValid验证通过
为什么呢因为1744-04 -6 是合法的
虽然这种概率很小就是某天0点的时间戳1744041600 恰好是一个时间格式时, 时间就显示错误了
如:20240507,202550408 ...

How

Date组件名字已经确定他是一个日期显示器不是日期范围显示器
所以修改Date组件兼容1744041600,1749139199 值,解析value取第一个有效的时间显示
不应该错误的吧1744041600,1749139199传给moment

@github-actions github-actions bot added the fix label Jun 4, 2025
@github-actions
Copy link

github-actions bot commented Jun 4, 2025

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

//时间范围格式修正
if (typeof value === 'string' && value.includes(',')) {
const values = value.split(',');
const firstValue = values.find(num => Number(num) > 0);
Copy link
Member

Choose a reason for hiding this comment

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

既然是日期范围的值给了日期展示,那值不一定都是时间戳,也可能是 2025/06/05 16:31:00,2025/06/05 16:32:00 这样,所以我觉得你直接分割后把第一段给 value 即可。而不是去找一个时间戳数字

Copy link
Contributor Author

Choose a reason for hiding this comment

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

确实取第一个即可

@2betop 2betop merged commit 8d24998 into baidu:master Jun 6, 2025
3 checks passed
@web-97 web-97 deleted the feat-date branch June 9, 2025 03:27
2betop added a commit that referenced this pull request Jul 2, 2025
2betop added a commit that referenced this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants