I am using date-fns to check if the 2 dates are on the same week or not.
following the documentation If I do :
const isSameWk = isSameWeek(
new Date("2023-02-05"),
new Date("2023-02-06"),
{ weekStartsOn: 0, locale: "en-GB" }
);
If I do the above snippet it will say true which is correct but it throws the error that I need to use parseISO since the new beta v2
so using parseISO
this way
const isSameWk = isSameWeek(
parseISO(new Date("2023-02-05")),
parseISO(new Date("2016-02-06")),
{ weekStartsOn: 0, locale: "en-GB" }
);
or
const isSameWk = isSameWeek(
parseISO("2023-02-05"),
parseISO(("2016-02-06")),
{ weekStartsOn: 0, locale: "en-GB" }
);
would not throw the error but console logging just this parseISO("2023-02-05") gives me the correct but not in my locale and logging parseISO(new Date("2023-02-05")) would give invalid date
Stuck on this for a long time can't figure out where am I wrong at.