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
Ability to explicitly pass timeZone to IntlProvider #702
Comments
@brichardssa is |
For our particular use case it is. I still think that the ability to provide defaultFormats for dates and numbers would make this a lot more user friendly |
@brichardssa I'd like to understand what those concrete uses cases would be that aren't handled by the named formats features and/or component reuse. Timezone is the main one that stands out to me that's in the same realm as I would rather accept a PR that just added support for |
I'll do that. I just think that giving people the ability to specify default formats in the form of the Intl documentation provides a more direct way for users to control the behaviour of react-intl |
The <IntlProvider
formats={{
date: {
foo: {
timeZone: 'Africa/Johannesburg',
},
},
}}
> I see how your PR #707 supports I think to make this work, we'd want to update the |
I'm definitely ok with a Defaults sound like they might come back to bite you. It's kind of like using context, but without seeing the context. |
@juandopazo the implementation detail we need to figure out is how to propagate the |
Just updated the title of this issue to reflect what we are trying to achieve here. Will look into this as soon as I get some time |
So... FYI, most browsers have trouble with arbitrary timezones: http://kangax.github.io/compat-table/esintl/#test-DateTimeFormat_accepts_IANA_timezone_names Firefox bug if you want to lobby for them to fix it: https://bugzilla.mozilla.org/show_bug.cgi?id=1266290 |
That's true. V8 logs a pretty straight forward error message when an unrecognised timezone is passed to it. Node < 6 give me this: "RangeError: Unsupported time zone specified Pacific/Samoa" It would be interesting to see what the other browsers do. |
Firefox and IE have the same issue. And the biggest problem is the polyfill does not support them either. |
Has the timeZone prop been added to the IntlProvider. I pulled latest and didnt see the changes?can we now add the prop to the IntlProvider directly? |
Unfortunately not yet. In order to achieve this, we need to request some changes in one of react-intl's dependencies. |
- because of a different timezone of travis, this tests will not match the same time. With this open issue the problem could be fixed without changing FormattedValue component formatjs/formatjs#702
- because of a different timezone of travis, this tests will not match the same time. With this open issue the problem could be fixed without changing FormattedValue component formatjs/formatjs#702
@juandopazo What's the recommended way to handle this? Seems like Firefox supports this in a coming version (no idea how often they release nowadays) but IE11 and older Safari are still problematic. Right now IE11 outputs a long datetime string instead, when a timezone is specified. Is there a simple way to check if timezone is supported so it could fallback to browser tz, and couldn't that be added to react-intl? |
I found this polyfill works with ie11: date-time-format-timezone |
@brichardssa @ericf Do we have a solution that decided ? Would be greatly appreciated if you could let me know workable solution ? We are facing issue on IE when timezone is passed. |
Any news on #893? Would solve a lot of arbitrary timezone-prop passes... |
I'd like to be able to set default formats for the entire application which are used by each of the different format functions. Currently, when passing defaultFormats to IntlProvider, these formats are only used by the formatMessage function.
For example, if I want all times displayed in a specific time zone (namely Africa/Johannesburg), it would be useful to pass the following to IntlProvider:
The text was updated successfully, but these errors were encountered: