I've got a list of ISO 8601-compatible strings, some of which are dates (like '2022-12-25'), some are date-time values (like '2022-12-25T12:00'), and some have time zone info (like '2022-12-25T12:00-08:00[America/Los_Angeles]'.
Using the new Temporal API that's coming to JavaScript, is there one function I can call to parse all these strings into their corresponding Temporal types like Temporal.PlainDate, Temporal.PlainDateTime, Temporal.ZonedDateTime, etc.?
No, there is not a universal parse-into-any-
Temporal-type function that's built into the language.This is because the same string can be used to parse many different
Temporaltypes. To parse a string into aTemporaltype, you must know ahead of time what type you want.For example,
2020-04-25[u-ca=hebrew]can be successfully parsed byTemporal.PlainDate.from,Temporal.PlainMonthDay.from,Temporal.PlainYearMonth.from, or evenTemporal.PlainDateTime.from. This ambiguity requires choosing aTemporaltype before parsing.