The isSunday
function from the date-fns
library can be used to determine if a given date object is a Sunday or not. Here is an example of how to use it:
index.tsx197 chars8 lines
In this example, we first import the isSunday
function from the date-fns
library using the require
statement.
We then create two Date
objects representing August 1st and 2nd, 2021. We pass each of these Date
objects to the isSunday
function and log the result to the console.
The first call to isSunday
returns true
because August 1st, 2021 was a Sunday, while the second call returns false
because August 2nd, 2021 was not a Sunday.
gistlibby LogSnag