eduolalo / moment-business-days

This is a momentJS plugin that allows you to use only business days (Monday to Friday)
MIT License
240 stars 67 forks source link

.monthBusinessWeeks subtract holidays #84

Open FabriceReynolds opened 4 years ago

FabriceReynolds commented 4 years ago

When adding holidays such as from the documentation I would like to use the .monthBusinessWeeks api and receive an array of weeks minus the holidays so that I have true representation of what days of the month are working business days grouped by week. The current results gets all week days of a month grouped by week whether they are holidays or not.

var moment = require('moment-business-days');

var july4th = '07-04-2015';
var laborDay = '09-07-2015';

moment.updateLocale('us', {
   holidays: [july4th, laborDay],
   holidayFormat: 'MM-DD-YYYY'
});

var month = moment('09-01-2015', 'MM-DD-YYYY')
console.log(month.monthBusinessWeeks()[1].length) // -->  actual 5 expect 4 (minus laborDay )

Maybe I'm misunderstanding this but it would be useful to take into account holidays

Thanks