To use the eachWeekendOfYear
function from the date-fns
library in TypeScript, you need to:
Install the date-fns
library by running the following command in your terminal:
28 chars2 lines
Import the eachWeekendOfYear
function from the date-fns
library in your TypeScript file:
index.ts46 chars2 lines
Call the eachWeekendOfYear
function with a Date
object representing the year for which you want to get the weekends:
index.ts94 chars4 lines
In the above example, eachWeekendOfYear
will return an array of Date
objects representing the weekends of the year 2022.
Here's the complete TypeScript code:
index.ts141 chars6 lines
gistlibby LogSnag