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

FormattedMessage is not respecting then timezone #1219

Closed
couds opened this issue Dec 4, 2018 · 7 comments
Closed

FormattedMessage is not respecting then timezone #1219

couds opened this issue Dec 4, 2018 · 7 comments

Comments

@couds
Copy link

couds commented Dec 4, 2018

Bug

Expected behavior

When using the FormattedMessage Component and pass a date value show the date and time using the TimeZone defined on the Provider (As FormattedTime and intl.formatTime does

Current behavior

When Using the component FormattedMessage with a date on the message the timezone is not correct

Step to reproduce

  • Setup the IntlProvider with a timeZone different of your browser current one
  • Render the following:
<div>
  <FormattedMessage id="message with date" defaultMessage="the current time is: {date, time, short}" values={{ date: new Date() }} />
  <p>
    The current time is: <FormattedTime value={new Date()} />
  </p>
  <p>
    The current time is: {this.props.intl.formatTime(new Date())}
  </p>
</div>

Your Environment

Executable Version
npm ls react-intl 2.7.2
npm ls react 16.4.2
npm --version 6.4.1
node --version 10.12.0
OS Version
Manjaro Linux (Illyria) 18.0.0
Browser Version
Chromium 70.0.3538.110
Chrome 70.0.3538.110
@papasmile
Copy link
Contributor

Trying with
react-intl@2.7.2
react@15.6.2
OSX, Chrome Version 71.0.3578.98

and
<IntlProvider locale="en" timeZone="Asia/Tokyo">

I get:

the current time is: 12:15 PM
The current time is: 12:15 PM
The current time is: 12:15 PM

Maybe you want pastebin your full code or maybe someone can try on your exact react/OS/browser versions....

@dhlavaty
Copy link

@papasmile It seems, that it does not work still.

Pls check real example in codesandbox: https://codesandbox.io/embed/react-intl-test-hzj4v

@longlho
Copy link
Member

longlho commented Sep 18, 2019

Thanks for reporting! We'll take a look asap.

@longlho
Copy link
Member

longlho commented Sep 26, 2019

fixed in master

@longlho longlho closed this as completed Sep 26, 2019
@dhlavaty
Copy link

Seems to me, that fix is in v3.3.1 , but I think that it still does not work correctly.

See: https://codesandbox.io/embed/react-intl-test-hzj4v

@longlho longlho reopened this Sep 26, 2019
@longlho
Copy link
Member

longlho commented Sep 26, 2019

The root of the problem is fixed but there're some issues regarding defaultFormats, I'll try to tackle that next.

@longlho
Copy link
Member

longlho commented Sep 27, 2019

fixed & verified in 3.3.2

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

No branches or pull requests

5 participants