Closed adummy832 closed 3 years ago
Hello, I created https://github.com/kalmecak/moment-business-days/pull/91 to address this issue.
Can you tell me if this is behavior that you'd expect?
If i right understand that function, it should return array of weeks of array of working days. So for example in my location in january Red days are holiday. I change a little getBusinessWeeks function
while (!done) {
/*if (day.day() >= 1 && day.day() < 6)*/ if (day.isBusinessDay()){
daysArr.push(day.clone());
}
add result be come to
(6) [Array(0), Array(0), Array(5), Array(5), Array(5), Array(0)]
0: []
1: []
2: (5) [k, k, k, k, k]
3: (5) [k, k, k, k, k]
4: (5) [k, k, k, k, k]
5: []
length: 6
__proto__: Array(0)
No It correctly calculate customs holidays.
PS: I think also need check for non zero for last week of month
if (daysArr.length > 0 && daysArr.length < 5) {
weeksArr.push(daysArr);
}
Yes, that's the change I made, see here: https://github.com/kalmecak/moment-business-days/pull/91/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L207
The question is: do you want also empty weeks or not? What do you think makes more sense?
For me empty array is very informative. It gives number of weeks and if array empty it is mean that whole week is holidays. In my country ussualy first week of january is holliday.
HI, play a little bit with function and i have a extra empty week at the end of array. I changed condition for adding last week
var weeksCount = end.diff(startDate,'weeks', true);
weeksCount = (weeksCount > 0)?Math.ceil(weeksCount):Math.floor(weeksCount);
....
if (end.diff(day.add(1, 'd')) < 0) {
/*if (daysArr.length < 5) */
if (weeksArr.length < weeksCount){
weeksArr.push(daysArr);
}
done = true;
}
The title says it all and I think user defined holidays shoudn't be included on "monthBusinessWeeks"
Snippet
Tools