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

Add support for dateStyle and timeStyle for Android #926

Closed
dlebedynskyi opened this issue Feb 27, 2023 · 7 comments
Closed

Add support for dateStyle and timeStyle for Android #926

dlebedynskyi opened this issue Feb 27, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@dlebedynskyi
Copy link

dlebedynskyi commented Feb 27, 2023

Problem

Intl on Android is still missing dateStyle and timeStyle. iOS already has it since v0.12.

Solution

Ask is to add support for missing Intl.DateTimeFormat API for Android dateStyle/timeStyle.

Additional Context

If possible, would be great to add rest of missing API

to close rest of missing options on Intl.DateTimeFormat as polyfill for Intl.DateTimeFormat is complex and heavy, and is currently required when dateStyle/timeStyle are used.

Related #23 (comment)

@mganandraj
Copy link
Contributor

I've created a PR : #927

@neildhar

@dlebedynskyi
Copy link
Author

dlebedynskyi commented Apr 10, 2023

@mganandraj we did some local testing with your PR.
It looks like weekday: 'narrow' is still missing (spec). Any chance you can add it as well?

@mganandraj
Copy link
Contributor

Hi @dlebedynskyi, weekday: 'narrow' is implemented .. Do you have a specific test case that fails ?

facebook-github-bot pushed a commit that referenced this issue Apr 21, 2023
Summary:
This PR is adding implementation for dateStyle and timeStyle options to Intl:DateTimeFormat service for Android API 24+.

Issue No : #926

This PR is adding implementation for dateStyle and timeStyle options to Intl:DateTimeFormat service.

Pull Request resolved: #927

Test Plan: test262 based test suite is passing.

Reviewed By: mattbfb

Differential Revision: D45185307

Pulled By: jpporto

fbshipit-source-id: 611f16080eb2e652606d95e0502592f56970dd80
@dlebedynskyi
Copy link
Author

dlebedynskyi commented May 4, 2023

@mganandraj sorry for late reply.

We think there is a bug in how it is implemented.

The way it is done, it does not match the spec - https://tc39.es/ecma402/#datetimeformat-objects.

`If required is "date" or "any", then
a. For each property name prop of « "weekday", "year", "month", "day" », do
i. Let value be ? Get(options, prop).
ii. If value is not undefined, let needDefaults be false.

as example

const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0, 200));
// request a weekday along with a long date
let options = {
  weekday: "narrow"
};
console.log(new Intl.DateTimeFormat("en-US", options).format(date)); 
// outputs "W, 12/19/2012" which is wrong,

this should just be "W" since using "weekday" negates the need for defaults.

Fix that we tested was here in https://github.com/facebook/hermes/blob/main/lib/VM/JSLib/Intl.cpp#L272

- {u"weekday", platform_intl::Option::Kind::String, 0},
+ {u"weekday", platform_intl::Option::Kind::String, kDateRequired},

We had tested your change prior it was merged, and took time to find fix.
So maybe we can do PR now or you can some testing. I can also open separate issue if needed. WDYT?

@mganandraj
Copy link
Contributor

Hello @dlebedynskyi .. 100% agreed. This bug has existed from day 1 and somehow left unnoticed. We do run most relevant Test262 test cases which doesn't seem to cover this.

I'd appreciate if you can send a PR.

facebook-github-bot pushed a commit that referenced this issue Jul 24, 2023
Summary:
Original Author: anandrag@microsoft.com
Original Git: a72115f

This PR is adding implementation for dateStyle and timeStyle options to Intl:DateTimeFormat service for Android API 24+.

Issue No : #926

This PR is adding implementation for dateStyle and timeStyle options to Intl:DateTimeFormat service.

Original Reviewed By: mattbfb

Original Revision: D45185307

Pull Request resolved: #927

Reviewed By: neildhar

Differential Revision: D47690090

fbshipit-source-id: f43e36a6c16f092ec708bc69a4be34075f82ae4a
@nandorojo
Copy link

Hey all, would you recommend that we use #927 as a patch in our app? Or is there likelihood of this getting merged soon?

@neildhar
Copy link
Contributor

neildhar commented Feb 5, 2024

Hey @nandorojo, it looks like this was already merged in a72115f, and is present in RN 0.73. Closing this issue.

@neildhar neildhar closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants