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 parsing input value #4346

Closed
wants to merge 9 commits into from

Conversation

wenqi73
Copy link
Member

@wenqi73 wenqi73 commented Oct 25, 2019

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

默认的日期格式使用国际化文件中的 dateFormat 属性对应的值。

新功能

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

如何实现

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

Breaking Change

Changelog: https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md#200---2019-08-20
我们建议用户同步 NG-ZORRO 升级到 2.x 版本。

PR Checklist

Please check if your PR fulfills the 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

API has changed, please merge in 9.0.0.

@netlify
Copy link

netlify bot commented Oct 25, 2019

Deploy preview for ng-zorro-master ready!

Built with commit 512c85f

https://deploy-preview-4346--ng-zorro-master.netlify.com

@wenqi73 wenqi73 changed the title refactor(module:date-picker): update date-fns to 2.x feat(module:date-picker): support parsing input value Oct 25, 2019
@wzhudev wzhudev added PR: target-major 💔 Breaking Change This PR or the solution to this issue would introduce breaking changes labels Oct 25, 2019
@codecov
Copy link

codecov bot commented Oct 25, 2019

Codecov Report

Merging #4346 into master will increase coverage by 0.1%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #4346     +/-   ##
=========================================
+ Coverage   93.21%   93.31%   +0.1%     
=========================================
  Files         521      521             
  Lines       12814    12815      +1     
  Branches     2018     2011      -7     
=========================================
+ Hits        11944    11958     +14     
+ Misses        454      450      -4     
+ Partials      416      407      -9
Impacted Files Coverage Δ
components/date-picker/week-picker.component.ts 85.71% <ø> (ø)
components/date-picker/year-picker.component.ts 100% <ø> (ø)
components/comment/demo/list.ts 100% <ø> (ø) ⬆️
...e-picker/lib/calendar/calendar-header.component.ts 98.68% <ø> (+2.34%) ⬆️
components/date-picker/range-picker.component.ts 100% <ø> (ø)
components/date-picker/date-picker.component.ts 100% <ø> (ø)
components/date-picker/date-picker.module.ts 100% <ø> (ø)
components/comment/demo/editor.ts 100% <ø> (ø) ⬆️
components/date-picker/month-picker.component.ts 100% <ø> (ø)
components/calendar/date-table.component.ts 98.11% <100%> (+4.53%) ⬆️
... and 12 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 72bfd7a...51d41a5. Read the comment docs.

@wenqi73 wenqi73 changed the title feat(module:date-picker): support parsing input value WIP:feat(module:date-picker): support parsing input value Oct 25, 2019
@wenqi73 wenqi73 force-pushed the date-fns2.x branch 5 times, most recently from 5966f4c to 512c85f Compare October 31, 2019 12:22
@wenqi73 wenqi73 changed the title WIP:feat(module:date-picker): support parsing input value feat(module:date-picker): support parsing input value && default format Oct 31, 2019
@wenqi73 wenqi73 assigned hsuanxyz and unassigned simplejason Oct 31, 2019
@daxilsshah
Copy link

@wenqi73 Any updates on this PR? we're waiting for the release of these changes.

@wenqi73
Copy link
Member Author

wenqi73 commented Nov 21, 2019

@daxilsshah We are evaluating the breaking changes this feature and will give some feedback here.

this.cdr.markForCheck();
}

protected setFormat(): void {}
Copy link
Member

Choose a reason for hiding this comment

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

abstract

Copy link
Member Author

Choose a reason for hiding this comment

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

用了 implements 后就不能用 abstract 了。

@@ -21,6 +21,6 @@ import { Component } from '@angular/core';
]
})
export class NzDemoDatePickerFormatComponent {
dateFormat = 'yyyy/MM/dd';
monthFormat = 'yyyy/MM';
dateFormat = 'dd.MM.yyyy';
Copy link
Member

Choose a reason for hiding this comment

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

demo 可以不变吗?

@hsuanxyz hsuanxyz added this to the 9.0.0 milestone Dec 12, 2019
@zaideygrek
Copy link

zaideygrek commented Dec 20, 2019

Hello, what about this fix, do you need help? And is-it possible to add a mask on the input ? thanks a lot

@wenqi73 wenqi73 changed the title feat(module:date-picker): support parsing input value && default format feat(module:date-picker): support parsing input value Jan 9, 2020
@dylanvdmerwe
Copy link

Very interested in this PR.

@wenqi73
Copy link
Member Author

wenqi73 commented Mar 3, 2020

See #4833

@wenqi73 wenqi73 closed this Mar 3, 2020
@wenqi73 wenqi73 deleted the date-fns2.x branch April 22, 2020 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💔 Breaking Change This PR or the solution to this issue would introduce breaking changes PR: target-major PR: unreviewed
Projects
None yet
7 participants