Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / date-fns-utc / eachDayOfInterval.ts
blobcd9b83d1a0d937bb2f9d8c7dba4320dcd318a5be
1 const eachDayOfInterval = (start: Date, end: Date) => {
2     const endTime = end.getTime();
4     if (!(start.getTime() <= endTime)) {
5         throw new RangeError('Invalid interval');
6     }
8     const dates: Date[] = [];
10     const currentDate = new Date(start);
11     currentDate.setUTCHours(0, 0, 0, 0);
13     const step = 1;
14     while (currentDate.getTime() <= endTime) {
15         dates.push(new Date(currentDate));
16         currentDate.setUTCDate(currentDate.getUTCDate() + step);
17         currentDate.setUTCHours(0, 0, 0, 0);
18     }
19     return dates;
22 export default eachDayOfInterval;