-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new feature differenceInBusinessDays #1194
Add new feature differenceInBusinessDays #1194
Conversation
That sounds great, thank you! Please rebase with master so I can review the diff. |
afcee36
to
238457e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, the first argument should be the later date: difference(4, 2) // => 2
and difference(2, 4) // => -2
.
I'll finish the PR. |
- Swap arguments to make it consistent with `differenceInDays` and `differenceInCalendarDays`. - Substruct 1 from the result as the interval contains both starting and ending dates. - Rework the edge cases. - Improve the documentation.
Please note that I've changed the function behavior:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's done!
This PR was released as |
@kossnocorp - great work release this. We've been using a custom function with quite similar code in our code base. However, we also take into account 'holidays' by allowing an array of excluded dates to be passed. Would you be interested in a PR that allows people to add in an array of dates (holidays) to be excluded from differenceInBusinessDays? |
Sister PR to #1154
Should partly solve #584. Allthough it does not take holidays into consideration, it does exclude weekends and should have some value for end users.
All in all, it is just a thin wrapper around
eachDayOfInterval
, filtering out the weekends though.Example usage: