Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Is there one function I can call to parse any string into the appropriate JS Temporal type?

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.?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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 Temporal types. To parse a string into a Temporal type, you must know ahead of time what type you want.

For example, 2020-04-25[u-ca=hebrew] can be successfully parsed by Temporal.PlainDate.from, Temporal.PlainMonthDay.from, Temporal.PlainYearMonth.from, or even Temporal.PlainDateTime.from. This ambiguity requires choosing a Temporal type before parsing.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!