Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda