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(module:date-picker): support parse input value #4833

Merged
merged 11 commits into from
Mar 15, 2020

Conversation

wenqi73
Copy link
Member

@wenqi73 wenqi73 commented Mar 3, 2020

Close #4028
Close #3976
Close #2492
Close #4101

新功能

date-fns 1.x 不支持日期的反格式化,相关 issue 有:#4028 #3976 #2492 #4101
date-fnx 2.x 已支持该功能

date-fns 1.x does not support date parsing. Related issues are: #4028 #3976 #2492 #4101. date-fnx 2.x already supports [this feature] (https://date-fns.org/v2.9.0/docs/parse)

如何实现

由于 angular 的日期格式与 date-fns 的日期格式并不兼容。因此反格式化功能只有在用户引入了 date-fns 才能使用。

Since angular's date format and date-fns' date format are not compatible. Therefore, the parsing feature could only be supported when the user provides date-fns.

Breaking Change

我们推荐用户使用 date-fns 2.x 的新的 format 格式。同时也提供配置项将 1.x format 转为 2.x format,新旧 format 的对比参照这里

We recommend that users use the new format of date-fns 2.x, and we also provide configuration items to convert 1.x format to 2.x format. For a comparison of the old and new formats, refer to here.

@NgModule({
  ...
  imports     : [ NgZorroAntdModule ],
  providers: [
    { provide: NZ_DATE_LOCALE, useValue: enUS },
    // Set `dateFnsFormatConvert ` to convert format from v1 to v2
    { provide: NZ_DATE_FNS_COMPATIBLE, useValue: true }
  ]
})
export class AppModule { }

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

@codecov
Copy link

codecov bot commented Mar 3, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@374eb84). Click here to learn what that means.
The diff coverage is 88%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4833   +/-   ##
=========================================
  Coverage          ?   93.03%           
=========================================
  Files             ?      506           
  Lines             ?    12734           
  Branches          ?     1967           
=========================================
  Hits              ?    11847           
  Misses            ?      470           
  Partials          ?      417
Impacted Files Coverage Δ
components/comment/demo/list.ts 100% <ø> (ø)
...mponents/date-picker/lib/month-header.component.ts 100% <ø> (ø)
...omponents/date-picker/lib/date-header.component.ts 100% <ø> (ø)
components/comment/demo/editor.ts 100% <ø> (ø)
...omponents/date-picker/abstract-picker.component.ts 96.42% <100%> (ø)
components/comment/demo/basic.ts 100% <100%> (ø)
components/date-picker/picker.component.ts 93.9% <100%> (ø)
...omponents/date-picker/calendar-footer.component.ts 96% <100%> (ø)
components/i18n/date-config.ts 100% <100%> (ø)
components/date-picker/lib/date-table.component.ts 97% <100%> (ø)
... and 3 more

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 374eb84...316b2c4. Read the comment docs.

@wenqi73 wenqi73 force-pushed the update-datefns branch 2 times, most recently from bdc5505 to 100f1ed Compare March 3, 2020 11:21
@wenqi73 wenqi73 force-pushed the update-datefns branch 2 times, most recently from 10d594a to 8cd44d2 Compare March 4, 2020 16:48
@codecov
Copy link

codecov bot commented Mar 5, 2020

Codecov Report

Merging #4833 into master will increase coverage by 0.10%.
The diff coverage is 86.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4833      +/-   ##
==========================================
+ Coverage   91.45%   91.56%   +0.10%     
==========================================
  Files         542      543       +1     
  Lines       13673    13688      +15     
  Branches     2033     2029       -4     
==========================================
+ Hits        12505    12533      +28     
+ Misses        699      693       -6     
+ Partials      469      462       -7     
Impacted Files Coverage Δ
components/comment/demo/editor.ts 100.00% <ø> (ø)
components/comment/demo/list.ts 100.00% <ø> (ø)
...omponents/date-picker/lib/abstract-panel-header.ts 88.63% <0.00%> (ø)
...omponents/date-picker/lib/date-header.component.ts 100.00% <ø> (+9.09%) ⬆️
...ponents/date-picker/lib/decade-header.component.ts 78.57% <0.00%> (ø)
...mponents/date-picker/lib/month-header.component.ts 100.00% <ø> (+11.11%) ⬆️
components/core/time/candy-date.ts 89.51% <50.00%> (ø)
components/i18n/convert-tokens.ts 82.60% <82.60%> (ø)
components/i18n/date-helper.service.ts 86.84% <95.23%> (+11.84%) ⬆️
components/comment/demo/basic.ts 100.00% <100.00%> (ø)
... and 10 more

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 0bcd2a9...fcbd72c. Read the comment docs.

components/i18n/convert-tokens.ts Show resolved Hide resolved
components/i18n/nz-i18n.interface.ts Outdated Show resolved Hide resolved
docs/i18n.zh-CN.md Outdated Show resolved Hide resolved
components/i18n/date-config.ts Outdated Show resolved Hide resolved
components/i18n/convert-tokens.ts Outdated Show resolved Hide resolved
@vthinkxie vthinkxie merged commit 6a523ba into NG-ZORRO:master Mar 15, 2020
@valerio-lucantonio
Copy link

Hi, with which new version will this fix be delivered? thanks

@vthinkxie
Copy link
Member

9.0.0-beta.1

@wenqi73 wenqi73 deleted the update-datefns branch March 27, 2020 15:28
Ricbet pushed a commit to Ricbet/ng-zorro-antd that referenced this pull request Apr 9, 2020
* feat(module:date-picker): support parse input value

* test: fix tests

* chore: support datefnsCompat option

* fix: not import from i18n in core

* chore: change API name and add docs

* chore: change format convert from config to token

* docs: update docs

* chore: move some types

* docs: update docs for date-fns update

* chore: change name and add warning

* docs: update docs
Close NG-ZORRO#4028
Close NG-ZORRO#3976
Close NG-ZORRO#2492
Close NG-ZORRO#4101
@hsuanxyz hsuanxyz mentioned this pull request Apr 15, 2020
hsuanxyz pushed a commit to hsuanxyz/ng-zorro-antd that referenced this pull request Aug 5, 2020
* feat(module:date-picker): support parse input value

* test: fix tests

* chore: support datefnsCompat option

* fix: not import from i18n in core

* chore: change API name and add docs

* chore: change format convert from config to token

* docs: update docs

* chore: move some types

* docs: update docs for date-fns update

* chore: change name and add warning

* docs: update docs
Close NG-ZORRO#4028
Close NG-ZORRO#3976
Close NG-ZORRO#2492
Close NG-ZORRO#4101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants