To use the eachWeekendOfInterval function from date-fns in JavaScript, you first need to install the date-fns package:
index.tsx21 chars2 lines
Then, you can import the eachWeekendOfInterval function and use it to get an array of all the weekends within a given time interval:
index.tsx284 chars8 linesThe eachWeekendOfInterval function takes an object with a start and end property, which should be instances of the Date class. It returns an array of Date objects, which represent the weekends within the specified time interval.
Note that the eachWeekendOfInterval function uses the ISO week numbering system, where the first week of the year is the one that includes January 4th. This means that if January 1st falls on a Friday, the weekend following it will be considered as part of the 53rd week of the previous year, and will not be included in the result array.
gistlibby LogSnag