Skip to content
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

adding 2 weeks doesn't take business days into account? #71

Open
sam26880 opened this issue Apr 23, 2019 · 1 comment
Open

adding 2 weeks doesn't take business days into account? #71

sam26880 opened this issue Apr 23, 2019 · 1 comment

Comments

@sam26880
Copy link

I have this code which returns 5/7/2019 when adding 2 weeks to today's date which is 4/23/2019
I have set the setting that says that Thursday is NOT a working day. So it should be skipping Thursday as well as weekend in this calculation. Am I correct?

Here's the code I have
this.task.FollowupDate = moment().businessAdd(2, 'weeks').format('MM/DD/YYYY');

it does seem to work correctly when I add 10 DAYS. It correctly skips Thursdays and Weekends.

So does this not work with WEEKS? or is that how it's supposed to work?

@mcdado
Copy link
Collaborator

mcdado commented Apr 27, 2019

Yeah… you're onto something: https://github.com/kalmecak/moment-business-days/blob/accaa23c28229d3ba6a2627a8eb30a364280d4ee/index.js#L95

At the moment this is how the plugin works: it adds takes 2 weeks, it iterates adding or subtracting one week (depending on which method is called), depleting the week counter only if the resulting day is a business day. This is a logic that works with days, but not weeks or months or years… my guess to how to fix this is "converting" weeks to days and using the same logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants