-
The following is giving me an unexpected answer: const { eachWeekOfInterval, parseISO } = require("date-fns");
const start = parseISO('2021-03-29T14:42:44.572Z');
const end = parseISO('2021-04-04T14:42:44.572Z');
console.log(eachWeekOfInterval({start, end}, {startsOn: 4}));
//0: Thu Mar 25 2021 00:00:00 GMT+0100 (Central European Standard Time)
//1: Thu Apr 01 2021 00:00:00 GMT+0200 (Central European Summer Time) I expected to receive only 1 entry for Thursday April 1 2021. |
Beta Was this translation helpful? Give feedback.
Answered by
fturmel
Jun 19, 2021
Replies: 1 comment
-
Hi @sfabriece, The way I understand it, by using March 29th is a Monday, and is part of the week that starts on Thursday March 25th. Hope that explains it! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tan75
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @sfabriece,
The way I understand it, by using
{ weekStartsOn: 4 }
you are defining Thursdays as the first day of the week. The default value for this option is 0 (Sunday).March 29th is a Monday, and is part of the week that starts on Thursday March 25th.
April 4th is a Sunday, and is part of the week that starts on Thursday April 1st.
Hope that explains it!