How to use the eachYearOfInterval function from date-fns

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

87
88
89
90
91
92
93
94
95
96
97
      return [formatDate(start), formatDate(end)]
    })
}


function getYears(from = BEGINNING, to = new Date()) {
  return eachYearOfInterval({start: from, end: to})
    .map(start => {
      const end = endOfYear(start)
      return [formatDate(start), formatDate(end)]
    })
fork icon1
star icon2
watch icon0

+ 3 other calls in file

138
139
140
141
142
143
144
145
146
147
    }
    lastDay = new Date(subIntervalBreaks[subIntervalBreaks.length - 1]);
    subIntervalBreaks.push(dateFns.addMonths(lastDay, 1));
    break;
case 'year':
    subIntervalBreaks = dateFns.eachYearOfInterval(queryInterval);
    if (subIntervalBreaks.length === 0) {
        subIntervalBreaks = [
            dateFns.startOfYear(queryInterval['start']),
            dateFns.addMilliseconds(dateFns.endOfYear(queryInterval['end']), 1)
fork icon1
star icon0
watch icon0

186
187
188
189
190
191
192
193
194
195
        return false;
    if (upper && dateFns.getYear(target) > dateFns.getYear(upper))
        return false;
    return true;
};
const years = vue.computed(() => dateFns.eachYearOfInterval({
    start: from.value,
    end: to.value,
}).map((value) => ({
    value,
fork icon0
star icon0
watch icon0

+ 9 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)