Tuning behaviour of Luxon toRelative, around year cross-over?

21 views Asked by At

We are using Luxon in a Javascript frontend project, and are running into a small issue where a date 20 December 2023, is showing as "last year" when using toRelative() on 11 January 2024.

Our expectation is that "last year" would be used only if the date range is sufficiently large (maybe 10 months or 365 days?) and anything below that would be in the form of "last month ago" or "2 months ago".

The toRelative() function does support a unit option, which can take an array and while we could provide ["months", "days", "hours", "minutes", "seconds"], this would remove the use of year from relative time.

Is there any way to get Luxon to provide the behaviour we are looking for and if so, can you share an example.

0

There are 0 answers