16.0.0 âĸ Published 12 months ago
@alanszp/business-days-date-fns v16.0.0
đ business-days-date-fns
An wrapper of some functionalities of date-fns with a custom non business days calendar.
đ Why?
date-fns
is great, but maybe you want to control dates using a your self calendar. This library allow you to do this.
â TD;LR
This library is like isWeekend that excludes Saturday and Sunday but excluding the dates of your calendar too
đšī¸ Features
- addBusinessDays, differenceInBusinessDays and subBusinessDays implementation and new functions: isNonBusinessDay, isBusinessDay,
- cache storage for a better performance
Async implementation
const {
addBusinessDays,
subBusinessDays
differenceInBusinessDays,
isNonBusinessDay,
isBusinessDay
} = withNonBusinessDays(({ year }) => {
return fetch(`${MY_API_CALENDAR}?year=${year}`)
})
const result = await addBusinessDays(new Date("2022-01-01"), 10, { year: 2022 })
Sync implementation
const {
addBusinessDays,
subBusinessDays
differenceInBusinessDays,
isNonBusinessDay,
isBusinessDay
} = withNonBusinessDays([
new Date('2022-01-01'),
new Date('2022-01-10')
])
const result = addBusinessDays(new Date("2022-01-01"), 10)
15.0.0
1 year ago
16.0.0
12 months ago
14.0.0
1 year ago
13.0.0
1 year ago
12.0.3
1 year ago
12.0.0
1 year ago
12.0.1
1 year ago
12.0.2
1 year ago
11.0.0
1 year ago
10.0.0
1 year ago
10.0.1
1 year ago
9.0.0
2 years ago
8.0.0
2 years ago
7.0.0
3 years ago
6.0.0
3 years ago
5.0.0
3 years ago
4.0.12
3 years ago
4.0.11
3 years ago
4.0.10
3 years ago