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

ISO dates loaded to the reactive forms are showing invalid date #4020

Closed
tbadlov opened this issue Mar 16, 2018 · 6 comments
Closed

ISO dates loaded to the reactive forms are showing invalid date #4020

tbadlov opened this issue Mar 16, 2018 · 6 comments

Comments

@tbadlov
Copy link

tbadlov commented Mar 16, 2018

Bug description or feature request:

when an ISO date format is loaded to a reactive model it shows an invalid date.

Plunker/StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-dpshux

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 2.0.3

Angular: 5.2.8

Bootstrap: 4.0

Build system: Angular CLI, System.js, webpack, starter seed:

Angular CLI 1.7.3

@IlyaSurmay
Copy link
Contributor

Datepicker model format is a Date object and you provided a string. This string has to be converted into a Date object before using it in datepicker.

@tbadlov
Copy link
Author

tbadlov commented Mar 22, 2018

It used to work with version 2.0.beta8

@coffeymatt
Copy link

@IlyaSurmay I think this should be reopened, datepicker should work with iso strings. Otherwise I have to process every date in the output from an api.

@grantbowering
Copy link

agreed with the above; this means we can't just materialize from json and bind with ngModel, we have to transform it. And it means that in typescript, if I expect it to be materialized as a string, but datepicker needs it as a Date, then I have to set that field in the dto's interface to type any so that I can assign a Date to it programmatically on load, and that's just weird.
Is this really the intent/policy of this project? I notice that writeValue(value: Date | string)...

@tbadlov
Copy link
Author

tbadlov commented May 21, 2018

What's the rational behind making the property strict to Date type? No service will provide you a date property in the type Date so it is literally causing us to write unnecessary code to instantiate a date object with the property of the ISO date string. It should just allow to accept both (Date | string)

@akvaliya
Copy link

akvaliya commented Apr 4, 2019

This should reopened. This is really weird behavior. I am using reactive forms & facing the exact same issue. Any updates on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants