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

feat: support date-fns in Picker #25822

Merged
merged 5 commits into from
Jul 27, 2020
Merged

Conversation

fireairforce
Copy link
Member

@fireairforce fireairforce commented Jul 26, 2020

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

ref issue is:
#22732
#21866

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Support date-fns library in Picker.
🇨🇳 Chinese DatePicker 组件支持 date-fns 日期库。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

View rendered docs/react/replace-moment.en-US.md
View rendered docs/react/replace-moment.zh-CN.md

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Jul 26, 2020

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Jul 26, 2020

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 26, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 808e373:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Jul 26, 2020

Codecov Report

Merging #25822 into feature will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           feature   #25822   +/-   ##
========================================
  Coverage    99.52%   99.52%           
========================================
  Files          374      374           
  Lines         7300     7300           
  Branches      2037     2037           
========================================
  Hits          7265     7265           
  Misses          35       35           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3247772...808e373. Read the comment docs.

@@ -5,7 +5,7 @@ title: 替换 Moment.js

## 如何在 DatePicker 中使用自定义日期库(如 dayjs )?

考虑到包的大小,你可以用自定义日期库替换 Moment。在这里我们提供了两种方式来实现替换:
考虑到包的大小,你可以用自定义日期库(目前支持 dayjs、date-fns)替换 Moment。在这里我们提供了两种方式来实现替换:
Copy link
Contributor

Choose a reason for hiding this comment

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

替换方式能类比么,从 datefns 导出的东西和 dayjs 一致?还有对 date-fns 的支持要加上版本提醒

Copy link
Member Author

Choose a reason for hiding this comment

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

嗯嗯,是类似的,都是通过 generate 的方式去生成,这里有些细节我补一下。

@@ -5,7 +5,7 @@ title: 替换 Moment.js

## 如何在 DatePicker 中使用自定义日期库(如 dayjs )?

考虑到包的大小,你可以用自定义日期库替换 Moment。在这里我们提供了两种方式来实现替换:
考虑到包的大小,你可以用自定义日期库(目前支持 dayjs、date-fns)替换 Moment。在这里我们提供了两种方式来实现替换:
Copy link
Contributor

Choose a reason for hiding this comment

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

替换方式能类比么,从 datefns 导出的东西和 dayjs 一致?还有对 date-fns 的支持要加上版本提醒

@fireairforce
Copy link
Member Author

新增了一下文档~可以CC


### DatePicker.tsx

Create `src/components/DatePicker.tsx`。
Copy link
Contributor

Choose a reason for hiding this comment

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

英文句号

@@ -5,7 +5,7 @@ title: Replace Moment.js

## How to use DatePicker with a custom date library like dayjs

Considering it's bundle size, you might want to replace Moment.js with a different date library of your choice. We provide two ways to customize which date library is used:
Considering it's bundle size, you might want to replace Moment.js with a different date library(now support dayjs and date-fns) of your choice. We provide two ways to customize which date library is used:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Considering it's bundle size, you might want to replace Moment.js with a different date library(now support dayjs and date-fns) of your choice. We provide two ways to customize which date library is used:
Considering it's bundle size, you might want to replace Moment.js with a different date library (now support dayjs and date-fns) of your choice. We provide two ways to customize which date library is used:

@fireairforce
Copy link
Member Author

已经修改了~

@fireairforce
Copy link
Member Author

image

lint看上去不是我这边的,我这边已经 rebase 到最新的了~

@afc163 afc163 mentioned this pull request Jul 27, 2020
@kerm1it
Copy link
Member

kerm1it commented Jul 27, 2020

@fireairforce 这个对应的依赖已经在主分支上更新了,rc-picker@1.15.0

@kerm1it
Copy link
Member

kerm1it commented Jul 27, 2020

@afc163 这个直接合到master吧?

@fireairforce
Copy link
Member Author

我用feature rebase 了一次

@fireairforce
Copy link
Member Author

现在应该阔以了~

@07akioni 07akioni merged commit 1638a9c into ant-design:feature Jul 27, 2020
@fireairforce fireairforce deleted the date-fns branch August 2, 2020 08:44
@paxarpp
Copy link

paxarpp commented Jan 2, 2021

hello,
the suggested use case for date-fns does not work for ru localization,
perhaps there is some solution for localization other than the default en

@Makentosh
Copy link

Hello,
yes,really date-fns does not work if localization through configprovider is ru
for a long time I couldn't understand why the datepicker doesn't work

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

7 participants