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

Error formatting time with timeStyle #2410

Closed
jeffal opened this issue Dec 15, 2020 · 5 comments
Closed

Error formatting time with timeStyle #2410

jeffal opened this issue Dec 15, 2020 · 5 comments
Labels

Comments

@jeffal
Copy link

jeffal commented Dec 15, 2020

Which package?
@formatjs/intl, more specifically: https://github.com/formatjs/formatjs/blob/main/packages/intl/src/dateTime.ts

Describe the bug
I did not set option hour and I receive the following error: Error formatting time. Can't set option hour when timeStyle is used.

To Reproduce

  1. Use FormattedTime component
  2. Set value
  3. Set timeStyle="short"
  4. See error

Expected behavior
There should be no error. The time should format as expected.

Screenshots
https://codesandbox.io/s/fragrant-wildflower-uswse?fontsize=14&hidenavigation=1&theme=dark

Desktop (please complete the following information):

  • OS: macOS Catalina 10.15.7
  • Browser: Chrome
  • Version: 87
@jeffal jeffal added the bug label Dec 15, 2020
@longlho
Copy link
Member

longlho commented Dec 15, 2020

Thanks for reporting this is indeed a bug historically in how we default certain options. Will fix soon.

@jeffal
Copy link
Author

jeffal commented Dec 16, 2020

I was thinking this may have to do with the following defaults being added here:
https://github.com/formatjs/formatjs/blob/main/packages/intl/src/dateTime.ts#L63-L71

@longlho
Copy link
Member

longlho commented Dec 16, 2020

Yup removing that might be a breaking change but would be more consistent w native API

longlho added a commit that referenced this issue Dec 16, 2020
longlho added a commit that referenced this issue Dec 16, 2020
dateStyle/timeStyle is used in formatTime
fix #2410
@longlho
Copy link
Member

longlho commented Dec 16, 2020

latest version (being published rn) should have the fix

@jeffal
Copy link
Author

jeffal commented Dec 16, 2020

Thanks for the amazingly quick response and fix!

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

No branches or pull requests

2 participants