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!
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.
yourInterval.length() will give you the length of the interval in milliseconds. So you need only find the interval with the highest result.