Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(date-picker): fix invalid date due to mismatch between date and format #2789

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

oljc
Copy link
Member

@oljc oljc commented Nov 11, 2023

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

问题:日期选择器中当传入的值与format不一致的时候会出现Invalid Date 导致组件无法正常运作
由于范围选择器就算不设置 format 但开启 showTime 时内部会默认给YYYY-MM-DD HH:mm:ss 所以表现尤为明显
image

原因:
追溯到全局组件通用date.ts函数文件中
dayjs扩展的 customParseFormat 插件使用条件如它文档第一句也就是传入的字符串格式需要和 format 尽可能一致(特性bug👀)
官网表现如图:
https://day.js.org/docs/zh-CN/parse/string-format

image

Solution

添加了有效日期校验 不满足时返回正常对象,进行输出兜底以保证组件正常运作。

How is the change tested?

Changelog

Component Changelog(CN) Changelog(EN) Related issues
date-picker 修复日期与format不一致导致出现无效日期 fix invalid date due to mismatch between date and format

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

@flsion flsion merged commit fb42186 into arco-design:main Nov 24, 2023
2 of 4 checks passed
@flsion flsion added this to the 2.53.3 milestone Nov 24, 2023
@oljc oljc deleted the fix-date-utils branch February 2, 2024 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants