-
Notifications
You must be signed in to change notification settings - Fork 161
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
Accept ISO 8601 Date-only string as input for IgxDateTimeEditorDirective #6994
Comments
There has been no recent activity and this issue has been marked inactive. |
We have a plan to refactor our date picker and time picker components where we will integrate our |
There has been no recent activity and this issue has been marked inactive. |
There has been no recent activity and this issue has been marked inactive. |
There has been no recent activity and this issue has been marked inactive. |
@pmoleri Our We will be handling ISO strings the way the browser does and as such, time shifts are to be expected in date only strings since they are defined as UTC according to the ecma spec. This means that any date only string that is bound to the editor will be directly given to the Please, do share your thoughts. |
So, my thoughts are: JS doesn't really support Date-only, it's always a timestamp. If I store a date-only string is because I care about that specific date (like birthday, anniversary, holiday, etc), so IMO time-shift is not an option. I'm in GMT-3, meaning that time-shift will actually change the date. I think supporting date-only strings is an improvement on Calendar / Date Picker. And, I think it should be encouraged, as date-only string is a much better representation of a Day than the JS Date object (which is actually a UTC timestamp). PS: In the future, when |
@pmoleri, we had a meeting two days back with @Lipata, @damyanpetev, @kdinev and @rkaraivanov about this and there it was decided that we don't want to fully support date only strings as described in this issue. We want our editors to handle dates the way the browser does it and to only emit date objects. If we support date only strings and allow bindings to them then we will also have to consider what to return to the user. For example, if you have a bound string '2020-03' (which is a valid ISO string) then should we emit the value in the exact same format as it was provided or should we append a default value of, say, "-01"? This brings another problem, if we emit the value in the same format then some information may be lost. Because if you initially have '2020-03' and update the Also, the workaround with "T00:00:00" seems intended because according to the ecma spec if we have a date only string it is interpreted as a UTC time while strings with a specified time portion are treated as local time. |
Not sure what this means. This is the opposite to what
That's not a valid date-only string, that's a string representing a month. So, it's valid for a month picker, not a date picker. In date picker, if you are to support this, you should return standard iso date-only string like
Yes, ECMA spec is a mess, and they are working towards fixing it. Why would we take that as an oracle of good date representation say in an API or a database? Do I need to mangle standard strings to accommodate for Ecma and Ignite? This is my feedback, it's no blocking for us. I just think that switching from standard |
…#6483 (#9160) * feat(*): add PickersBaseDirective * feat(date-time-editor): handling for wheel events * feat(types): add new enum HeaderOrientation * feat(date-time-editor): add preventSpeenOnWheel input * feat(date-time-editor): can be set to suppress focus * feat(DatePickerUtils): add method for min/max validation * refactor(CalendarContainer): move to date-utils * feat(PickersBaseDirective): implements EditorProvider * refactor(picker-icons): move picker icon components to date-common * feat(date-time-editor): add option to set spin delta per part #7169 (#8987) * refactor(date-range): pickers base, overlay service, template buttons, valueChange * refactor(date-editor): rename isSpinLoop to spinLoop * feat(date-time-editor, date-range-picker, date-picker): ISO 8601 support #6994 * feat(date-picker): add readonly prop, close on escape * refactor(advanced-filtering): update date picker template * refactor(filtering-row): update date picker template * refactor(excel-style-date-expr): update date picker template * refactor(input-directive): set disabled using hostbinding * feat(igx-time-picker): refactoring #6482 (#8947) * feat(date-time-editor, pickers): add migrations, changelog, readme #6482, #6483 (#9319) Co-authored-by: Boris <[email protected]> Co-authored-by: plamenamiteva <[email protected]>
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
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">
andigx-datepicker
, while using the same standard format for values.Related issues: #8256
The text was updated successfully, but these errors were encountered: