Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda