Skip to content

Commit

Permalink
oopsies
Browse files Browse the repository at this point in the history
  • Loading branch information
cbebe committed May 4, 2021
1 parent c942797 commit 7fc6355
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";
const yellow = ["#FFFFB7", "#FFF192", "#FFEA61", "#FFDD3C", "#FFD400"];
const Colours = { darkBlue: "colour" };
const dateToYMD = (date) => date.toISOString().slice(0, 10);
const increaseDate = (date) => new Date(date.setDate(date.getDate() + 1));
const createDateRange = (start, end) => {
const dateArr = [];
for (
let startCp = increaseDate(new Date(start));
startCp < end;
startCp = increaseDate(startCp)
) {
dateArr.push(new Date(startCp));
}
return dateArr;
};
const createMarkedDates = (start, end) => {
const startStr = dateToYMD(start);
const endStr = dateToYMD(end);
const selectedStr = createDateRange(start, end).map((d) => dateToYMD(d));
const markedDates = {
[startStr]: { startingDay: true, color: yellow[4], textColor: Colours.darkBlue },
};
selectedStr.forEach((dateStr) => {
markedDates[dateStr] = { selected: true, color: yellow[4], textColor: Colours.darkBlue };
});
markedDates[endStr] = { endingDay: true, color: yellow[4], textColor: Colours.darkBlue };
return markedDates;
};

let date = new Date();
let in14days = new Date(new Date(date).setDate(date.getDate() + 14));
console.log(createMarkedDates(date, in14days));

0 comments on commit 7fc6355

Please sign in to comment.