Skip to content

Make NativeDate.toLocaleString() behave more like real browsers#2338

Merged
gbrail merged 1 commit intomozilla:masterfrom
HtmlUnit:native_date
Mar 21, 2026
Merged

Make NativeDate.toLocaleString() behave more like real browsers#2338
gbrail merged 1 commit intomozilla:masterfrom
HtmlUnit:native_date

Conversation

@rbri
Copy link
Copy Markdown
Collaborator

@rbri rbri commented Mar 18, 2026

Co-authored-by: Lai Quang Duong

This PR does the following

Make toLocaleString(), toLocaleDateString(), and toLocaleTimeString() output closer to real browser behavior by building DateTimeFormatter dynamically using the resolved locale instead of static pre-built formatters.

Now the outputs are almost identical to real browser with the exception of some minor cases.

see HtmlUnit#20

@gbrail
Copy link
Copy Markdown
Collaborator

gbrail commented Mar 21, 2026

This looks good to me, and works, although I don't know if it will conflict with one of the upcoming PRs to convert descriptors - at some point we'll want to move Date away from IdFunctionObject. But it looks good to me, thanks!

@aardvark179
Copy link
Copy Markdown
Contributor

aardvark179 commented Mar 21, 2026

Rebasing that should be pretty easy, happy to see this go in.

Edit: wait, Date is already moved to descriptors.

@rbri
Copy link
Copy Markdown
Collaborator Author

rbri commented Mar 21, 2026

@aardvark179 yes its already descriptor based
@gbrail will be great if you can merge this (and hopefully this #2130 also :-))

@gbrail
Copy link
Copy Markdown
Collaborator

gbrail commented Mar 21, 2026

No worries, I was confused because in the PR I saw a switch statement, but I now see that's called in a helper function. I'll do this soon.

@gbrail gbrail merged commit ef13600 into mozilla:master Mar 21, 2026
11 checks passed
@rbri
Copy link
Copy Markdown
Collaborator Author

rbri commented Mar 21, 2026

Thanks

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

Successfully merging this pull request may close these issues.

3 participants