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

Date.toLocaleString uses "at" instead of "," with dateStyle: "medium" #6056

Open
bconnorwhite opened this issue Sep 25, 2023 · 4 comments
Open
Labels
bug Something isn't working jsc Something related to JavaScriptCore web-api Something that relates to a standard Web API

Comments

@bconnorwhite
Copy link

What version of Bun is running?

1.0.3+8677ae9fb154dea49939dd396fdd1363959f96de

What platform is your computer?

Darwin 22.5.0 arm64 arm

What steps can reproduce the bug?

console.log("long/long".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "long", timeStyle: "long" }));
console.log("long/medium".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "long", timeStyle: "medium" }));
console.log("long/short".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "long", timeStyle: "short" }));
console.log("medium/long".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "medium", timeStyle: "long" }));
console.log("medium/medium".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "medium", timeStyle: "medium" }));
console.log("medium/short".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "medium", timeStyle: "short" }));
console.log("short/long".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "short", timeStyle: "long" }));
console.log("short/medium".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "short", timeStyle: "medium" }));
console.log("short/short".padEnd(15), new Date().toLocaleString("en-US", { dateStyle: "short", timeStyle: "short" }));

What is the expected behavior?

Node:

long/long       September 25, 2023 at 6:04:20 PM CDT
long/medium     September 25, 2023 at 6:04:20 PM
long/short      September 25, 2023 at 6:04 PM
medium/long     Sep 25, 2023, 6:04:20 PM CDT
medium/medium   Sep 25, 2023, 6:04:20 PM
medium/short    Sep 25, 2023, 6:04 PM
short/long      9/25/23, 6:04:20 PM CDT
short/medium    9/25/23, 6:04:20 PM
short/short     9/25/23, 6:04 PM

What do you see instead?

Bun:

long/long       September 25, 2023 at 6:04:32 PM CDT
long/medium     September 25, 2023 at 6:04:32 PM
long/short      September 25, 2023 at 6:04 PM
medium/long     Sep 25, 2023 at 6:04:32 PM CDT
medium/medium   Sep 25, 2023 at 6:04:33 PM
medium/short    Sep 25, 2023 at 6:04 PM
short/long      9/25/23, 6:04:33 PM CDT
short/medium    9/25/23, 6:04:33 PM
short/short     9/25/23, 6:04 PM

Additional information

In Date.toLocaleString with dateStyle set to "medium", bun uses "at" to separate the date and time, while Node/Chromium use ",".

@bconnorwhite bconnorwhite added the bug Something isn't working label Sep 25, 2023
@bconnorwhite bconnorwhite changed the title Date.toLocaleString uses "," instead of "at" with dateStyle: "medium" Date.toLocaleString uses "at" instead of "," with dateStyle: "medium" Sep 25, 2023
@Electroid
Copy link
Contributor

Would you mind checking this in Chrome vs Safari?

@Electroid Electroid added the web-api Something that relates to a standard Web API label Sep 25, 2023
@bconnorwhite
Copy link
Author

Interesting, Chrome matches Node but Safari matches Bun, so I assume this is V8 vs. JSC?

@Electroid Electroid added the jsc Something related to JavaScriptCore label Sep 25, 2023
@Electroid
Copy link
Contributor

@bconnorwhite Yep, looks like either V8 or WebKit is wrong here. Would have to take a look at the spec to see.

@cyfung1031
Copy link
Contributor

cyfung1031 commented Sep 27, 2023

You might ask in ECMAScript Internationalization API Specification as WebKit shall follow ECMA402 since 2016 (https://webkit.org/blog/6978/javascript-internationalization-api/)

However, the WebKit blog links to the spec published in June 2015, and there are still discussions on the displayStyle in 2016.
tc39/ecma402#108
There might be changes after WebKit adopted the Spec 2.0

You might also check the latest spec https://tc39.es/ecma402/2022/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jsc Something related to JavaScriptCore web-api Something that relates to a standard Web API
Projects
None yet
Development

No branches or pull requests

3 participants