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 addBusinessDays #1154
Conversation
PS: Also planning on making a PR for a This is how I've solved the lack thereof so far: // Get a range or number of weekdays
export const weekDays = (start: DirtyDateType, end: DirtyDateType, asNumber: boolean = false) => {
const businessDays = eachDay(toDate(start), toDate(end)).filter(d => !isWeekend(d));
return asNumber ? businessDays.length : businessDays;
}; Is a function like this something that could be handy in your opinion? |
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.
I like the idea but weekday means any day, not just working days so I suggest naming it addWorkingDays
.
Update: I've figured that "business day" is more common term, so please name it |
6f23b5a
to
da817a6
Compare
Updated to |
da817a6
to
5e3e089
Compare
Thanks for the update! I see that the tests fail in The problem that your tests operate on the DST edge (which is a lucky coincidence) and it causes an hour shift. Look how Since your function, is affected by DST, please add a DST test. See:
Also, please rebase your branch with the fresh master. Please tell me if you need assistance! |
I'm not 100% sure I follow. More specifically, I'm unsure of:
PS: I'll likely only have time to get back to this in a few days. |
Alrighty, I'll proceed from here 👌 |
You can see the solution for the DST problem: 03bbf4d |
e5aae22
to
ec517d9
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.
It's complete.
This PR was released as |
Thanks a bunch for the help and finalisation! 🙌 I’ll try to take some time this weekend to check out how the final pieces actually connect with fixing the tests |
Its very unexpected that this function doesn't accept negative arguments. |
Should partly solve #584. Allthough it does not take holidays into consideration, I recon it might still have some value for end users.