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
kossnocorp
left a comment
There was a problem hiding this comment.
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:
|
|
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: