How to use the eachWeekOfInterval function from date-fns

Find comprehensive JavaScript date-fns.eachWeekOfInterval code examples handpicked from public code repositorys.

71
72
73
74
75
76
77
78
79
80
81
  return eachDayOfInterval({start: from, end: to})
    .map(start => [formatDate(start), formatDate(start)])
}


function getWeeks(from = BEGINNING, to = new Date()) {
  return eachWeekOfInterval({start: from, end: to}, {weekStartsOn: 1})
    .map(start => {
      const end = endOfWeek(start, {weekStartsOn: 1})
      return [formatDate(start), formatDate(end)]
    })
fork icon1
star icon2
watch icon0

+ 3 other calls in file

114
115
116
117
118
119
120
121
122
123
    }
    lastDay = new Date(subIntervalBreaks[subIntervalBreaks.length - 1]);
    subIntervalBreaks.push(dateFns.addDays(lastDay, 1));
    break;
case 'week':
    subIntervalBreaks = dateFns.eachWeekOfInterval(queryInterval);
    if (subIntervalBreaks.length === 0) {
        subIntervalBreaks = [
            dateFns.startOfWeek(queryInterval['start']),
            dateFns.addMilliseconds(dateFns.endOfWeek(queryInterval['end']), 1)
fork icon1
star icon0
watch icon0

23
24
25
26
27
28
29
30
31
32
33
34
}


const weeks = (start, end) => {
	const startDate = new Date(start);
	const endDate = new Date(end);
	return eachWeekOfInterval({start: startDate, end: endDate}).map((d) => format(d, "yyyy'W'I"))
}


const dataSets = [
	{
fork icon0
star icon0
watch icon0

+ 3 other calls in file

Other functions in date-fns

Sorted by popularity

function icon

date-fns.format is the most popular function in date-fns (3838 examples)