Fix business days counting in before/after methods #235
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reference
Issue 196
Description
Problem:
The counting of business days is inconsistent in
before
andafter
methods depending on whether the start date is a workday or not.When starting on a workday:
This only counts 4 workdays (Tue 14, Mon 13, Fri 10, Thu 9), instead of 5.
But when starting on a non-workday:
This correctly counts 5 workdays (Fri 14, Thu 13, Wed 12, Tue 11, Mon 10).
See also #196 (comment) for a more detailed explanation.
Solution:
Move one day first before starting the count:
This ensures we never count the start date itself, making the behavior consistent in all cases.