tc39 / proposals

Tracking ECMAScript Proposals
https://tc39.github.io/process-document/
18.12k stars 713 forks source link

Any way to get a date from a locale date string? #454

Closed tounsoo closed 1 year ago

tounsoo commented 1 year ago

I have a following use case: When I have locale set to en-gb and enter 23/01/2023 I need it to be able to get correct javascript date but I don't see a way to get it using Intl. Maybe there is already a proposal with it? If so please point me to it Thank you!.

// Kinda want something like DateTimeFromLocale
const dateFromEnGB = new Intl.DateTimeFromLocale('en-gb').format('23/01/2023').toFormat({
        day: '2-digit',
        month: '2-digit',
        year: 'numeric',
});
ptomato commented 1 year ago

Hi, thanks for the suggestion. You're not alone as many people have suggested this; it seems like a simple thing to do but it's actually problematic for several reasons. I recommend you read the discussion in https://github.com/tc39/ecma402/issues/342 as a background. There's also a thread at https://github.com/js-temporal/proposal-temporal-v2/issues/2 to discuss about possibly including a limited version of it in a future proposal.

(I'll close this issue as this isn't the place to request the creation of a proposal — discussion should continue in one of those two places or on our Discourse instance, https://es.discourse.group)