Skip to content

Instantly share code, notes, and snippets.

@radiocity
Created August 3, 2024 19:35
Show Gist options
  • Save radiocity/a90716c77a81abfee0ee7a96c70e06cb to your computer and use it in GitHub Desktop.
Save radiocity/a90716c77a81abfee0ee7a96c70e06cb to your computer and use it in GitHub Desktop.
export default (startDate, endDate) => {
const result = [];
const currentDate = startDate;
while (currentDate <= endDate) {
const day = currentDate.getDay();
if (day !== 0 && day !== 6) {
result[result.length] = new Date(currentDate.getTime());
}
currentDate.setDate(currentDate.getDate() + 1);
}
return result;
};
@radiocity
Copy link
Author

const begin = new Date();
const end = new Date();
end.setDate(end.getDate() + 7);
console.log(getBusinessDays(begin, end));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment