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

[Ic-Date-Input / IcDate-Picker] - Add support for UTC format in icChange event output #3142

Open
ad9242 opened this issue Feb 5, 2025 · 0 comments

Comments

@ad9242
Copy link
Contributor

ad9242 commented Feb 5, 2025

Summary

Currently the format of the output from the icChange event is a Javascript date, which can depend on locale settings. The proposal is to additionally return the value in UTC format

💬 Description

In the following Stackblitz example, depending on system date settings, is is possible to enter a date but then when converting the value emitted from the date-input\picker to IsoString format, it may return the day before

For example:

Image

There is a workaround as show in that stackblitz to first convert the date to UTC, but it would be nice if the event contained the value in that format

const dateChangedHandler = (event) => {
    const val = event.detail.value;
    console.log('iso string1 is ', val.toISOString());
    const date = new Date(event.detail.value);
    const UTC = new Date(
      Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
    );
    const isoString = UTC.toISOString();
    console.log('UTC is ', UTC);
    console.log('iso string2 is ', isoString);

the existing value could be returned in addition to the UTC format:

this.icChange.emit({ value: d, utcValue: <the utc format value> });

💰 Use value

It would save users having to convert the date themselves

📝 Acceptance Criteria

If relevant, describe in full detail the different interactions and edge cases that the component or patterns needs to fulfil.

Given a date input\picker
When the value is changed
Then an event is emitted with the value in UTC format

Additional info

If not implemented in the short term, it would be good to add an example on the site that shows the workaround in the meantime

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

No branches or pull requests

1 participant