business-day
v1.1.0
Published
Let your date libaray like Moment.js can count holidays!
Downloads
13
Maintainers
Readme
business-day
Let your date libaray like Moment.js can count holidays!
features
- [x] configurable workdays (default: Mon. -> Fri.)
- [x] configurable holidays
- [x] configurable make-up days
- [x] support Moment.js
- [x] support Day.js
- [x] support date-fns
- [ ] fully tests
install
# use npm
yarn add business-day
# use npm
npm i business-day
usage
import moment from 'moment'
import { MomentCore as BusinessDay } from 'business-day'
// 2020-12-01 (Tuesday), 2020-12-02 (Wednesday)
BusinessDay.setConfig({ holidays: ['2020-12-01'] })
const day1 = moment('2020-11-30')
console.log(BusinessDay.addBusinessDays(day1.toDate(), 1))
// Moment<2020-12-02T00:00:00+08:00>
BusinessDay.setConfig({ holidays: ['2020-12-01', '2020-12-02'] })
const day2 = moment('2020-11-30')
console.log(BusinessDay.addBusinessDays(day2.toDate(), 1))
// Moment<2020-12-03T00:00:00+08:00>