Describe the bug
The Date.prototype.toLocaleString is not working as expected, it always adds both date and time when call it with dateStyle/timeStyle option.
To Reproduce
const date = new Date(Date.UTC(2024, 2, 10, 2, 30))
console.log(date.toLocaleString("en-US", {dateStyle: "short"}))
console.log(date.toLocaleString("en-US", {timeStyle: "short"}))
Expected behavior
Running this code, 3/10/24 and 2:30 AM should be printed, but instead we get 3/10/24, 2:30:00 AM and March 10, 2024 at 2:30 AM. The expected behavior can be found in steps 30-31 of this ECMAScript specification part.
Describe the bug
The
Date.prototype.toLocaleStringis not working as expected, it always adds both date and time when call it withdateStyle/timeStyleoption.To Reproduce
Expected behavior
Running this code,
3/10/24and2:30 AMshould be printed, but instead we get3/10/24, 2:30:00 AMandMarch 10, 2024 at 2:30 AM. The expected behavior can be found in steps 30-31 of this ECMAScript specification part.