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

161
Visualizações
How do I compare Durations or Intervals in Luxon?

I have an Interval[], and I'd like to know which is the largest interval. I thought that converting them to Durations and then comparing may work, but I can't find appropriate methods in the luxon docs, and Google is getting me nowhere.

How do I compare durations or intervals? Thanks!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

One way is you can convert the date you have to an ISO string and then use diff to get the difference. https://moment.github.io/luxon/#/math?id=diffs.

var end = DateTime.fromISO('2017-03-13');
var start = DateTime.fromISO('2017-02-13');

var diffInMonths = end.diff(start, 'months');
diffInMonths.toObject(); //=> { months: 1 }

That's the example they show in that documentation.

You can also convert the date to a unix timestamp and subtract them to get a difference, after which you convert it back to a date.

If you didn't know "Luxon" is the improved package of the (now deprecated) "moment" package, that's why the documentation is still using moment.

For any more help than that I'd like more information on what exactly you're struggling with and see what you've already tried.

about 4 years ago · Juan Pablo Isaza Relatório

0

yourInterval.length() will give you the length of the interval in milliseconds. So you need only find the interval with the highest result.

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