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

Date format has invisible characters in IE11 #201

Closed
MattHo opened this issue Nov 3, 2015 · 4 comments
Closed

Date format has invisible characters in IE11 #201

MattHo opened this issue Nov 3, 2015 · 4 comments

Comments

@MattHo
Copy link

MattHo commented Nov 3, 2015

formatDate function from react-intl returns date with U+200E (left-to-right marker) characters in IE11. Since the same function returns date without these characters in server, this causes checksum mismatch. Please fix formatDate() to return date string without any invisible characters.

@ericf
Copy link
Collaborator

ericf commented Nov 3, 2015

There is a detailed description and discussion of this issue at the ECMA 402 spec level: tc39/ecma402#28

I searched through all the CLDR locale data used by the Intl.js polyfill and \u200E isn't used for dates, but it is used for Farsi (fa) currency formatting, it would be rendered incorrectly if stripped from fa when formatting numbers.

We also can't blinding strip the LRMs and RLMs characters they are there for a reason — to provide bidi hits on structured text. If they are removed it will lead to incorrect and incomprehensible strings in the UI.

var df = new Intl.DateTimeFormat('ar', {
    day  : 'numeric', 
    month: 'numeric', 
    year : 'numeric'
});

var withRLMs    = df.format(Date.now());
var withoutRLMs = df.format(Date.now()).replace(/\u200F/g, '');

console.log(withRLMs);    // "٣‏/١١‏/٢٠١٥"
console.log(withoutRLMs); // "٣/١١‏/٢٠١٥"

In the above example, the expected output for Arabic is "year/month/day", if the RLMs are removed, it ends up being "year/day/month" which is incorrect and would confuse the user.

The issue here is that IE adds some redundant, but valid, LRM chars, these are safe to strip in most cases, but not the Farsi one mentioned above.


There's a larger issue here for dates and React checksum though: timezones. While the ECMA 402 spec and JavaScript implementations support timezones for date/time formatting, the Intl.js polyfill does not (because of the size of the data), and the polyfill is required for Node 0.10. Node 0.12+ has built-in Intl support and therefore supports specifying a timezone.

Even if IE used the CLDR like Chrome and Firefox for its backing locale data, we still have the issue of Node 0.10 and timezones being different from server to client causing checksums to fail. Because of this, I'm thinking of solution that also updates the client after componentDidMount.

With relative times, I've implemented a similar solution to avoid checksum mismatches: #191

@dgieselaar
Copy link

We have this as well. I would have expected a little more activity at least in this issue. Do people just not care about IE, or am I missing some obvious workaround?

@stale
Copy link

stale bot commented May 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 30, 2019
@stale
Copy link

stale bot commented Jun 6, 2019

Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information.

@stale stale bot closed this as completed Jun 6, 2019
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

3 participants