Skip to content

Date.prototype.toLocaleString behavior violates the ECMA-402 #5323

@Vellumic

Description

@Vellumic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions