eduolalo / moment-business-days

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

Get all selected dates excluding holidays #102

Closed tdrabikdev closed 2 years ago

tdrabikdev commented 2 years ago

Hello guys is any change to get all dates excluding holidays?

I want to store each date in database. But how get list of all dates?

tdrabikdev commented 2 years ago
            let startDate = moment(arg.startStr);
            let endDate = moment(arg.endStr);
            let date = [];
            for (let m = moment(startDate); m.isBefore(endDate); m.add(1, 'days')) {
                if(m.isBusinessDay()){
                    date.push(m.format('YYYY-MM-DD'));
                }
            }
            console.log(date);

If Somebody looking for something similar :)