-
Notifications
You must be signed in to change notification settings - Fork 160
Description
Problem
Calendar and DatePicker use Date class. Date class represents a timestamp which is often troublesome to handle date-only values.
OpenAPI (swagger) defines format date to be a date-only string (e.g. 2017-07-21).
Currently the Calendar doesn't allow to use information from a Rest endpoint, conforming to the Swagger date format, to display a birthday calendar, or and date picker like <input type="date" /> allows.
I need to first create Date instances time-shifted to my local time so Calendar is able to display them correctly. The same will happen for other concepts as Holidays, target release date, etc.
e.g. new Date('2020-03-27') -> 2020-03-26 21:00:00 GMT-0300 (this makes the Calendar display the wrong date).
Describe the solution you'd like
Calendar and DatePicker could accept ISO 8601 dates. To internally convert those strings to Date objects or not is an implementation decision, if it's converted it should parse it in a way that it's interpreted as local time, but this should be transparent to the user.
It should also be possible to subscribe to changes using ISO 8601 Date strings, e.g. currently calendar onSelection emits Date objects.
Describe alternatives you've considered
Create a pipe to transform the date-only strings to local Dates
return new Date('2020-03-27' + 'T00:00:00'); // adding time with no timezone makes it parse it as local time.
When subscribing to changes I would need to do a conversion to serialize back to date-only strings.
The pipe (input) could be provided by igniteui to use optionally, but this wouldn't solve the subscribe (output) issue.
Additional context
HTML <input type="date" /> accepts and emits ISO Date-only strings, just like the swagger format.
By implementing this feature, it allows to switch between <input type="date"> and igx-datepicker, while using the same standard format for values.
Related issues: #8256