Relative time
We use methods from Luxon's DateTime instances.
describe the distance in time from now
A relative time describes how far we are, as of now, from an event that happens in the past or in the future. It is a duration relative to now. We focus on the duration, such as 3 hours ago, or in 2 minutes.
dt.toRelative() // "4 hours ago"
dt.toRelative() // "in 2 days"
dt.toRelative({ style: "short" }) // "4 hr. ago"
dt.toRelative({ style: "narrow" }) // "4h ago"
dt.toRelative({ unit: "seconds" }) // "300 seconds ago"
dt.toRelative({ unit: "years" }) // "1 year ago"
dt.toRelative({ round: false }) // "4.5 hours ago"
dt.toRelative({ base: anchor }) // "5 years ago"
prioritize the calendar aspects, day granularity, day and month difference
We describe where the event takes place in the calendar relative to now. It uses calendar date components, with precision capped to day difference, such as today or yesterday.
dt.toRelativeCalendar() // "today"
dt.toRelativeCalendar() // "yesterday"
dt.toRelativeCalendar() // "tomorrow"
dt.toRelativeCalendar() // "2 days ago"
dt.toRelativeCalendar() // "last month"