Skip to content

Intl.DateTimeFormat needs a parser #342

Closed

Description

An instance of DateTimeFormat can do Date -> string but cannot do the reverse string -> Date for formatted strings it created.

It's very hard to implement that in user-land because different browsers might handle different languages in different ways?

My proposal is a parse method that is reverse of the format method:

const x = new Intl.DateTimeFormat(/* format options */);

// true, assuming format options are lossless
x.parse(x.format(aDate)).getTime() === aDate.getTime()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    c: datetimeComponent: dates, times, timezonesenhancements: commentStatus: more info is needed to move forward

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions