I’m trying to define holidays in Luxon, such as memorial day which is the last Monday of May. How can I generate a luxon date object with this:
DateTime.now().set({ month: 5, weekday: 1 })
Is there a way to specify last week in Luxon without knowing the exact date?
2
Answers
From my understanding, Luxon’s weeks always start on Monday, so asking for the start of the week after getting the end of the month of May should get you the last Monday of May (of the current year if your starting point is
DateTime.now()
).You can, of course also do it without Luxon by using some basic
Date
functionality: