@alanszp/business-days-date-fns
TypeScript icon, indicating that this package has built-in type declarations

15.0.0 • Public • Published

📆 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

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)

Readme

Keywords

none

Package Sidebar

Install

npm i @alanszp/business-days-date-fns

Weekly Downloads

115

Version

15.0.0

License

MIT

Unpacked Size

598 kB

Total Files

56

Last publish

Collaborators

  • fedekiwo
  • alansz