Skip to content

Help validate javascript dates whether there are business date, holidays, week days or weekend days.

License

Notifications You must be signed in to change notification settings

Tochemey/business-date-checker

Repository files navigation

Business Date Library

Node.js Typescript library for business date manipulation and validation for backend applications.

ci codecov

This libary helps validate business days, weekend days, week days and holidays for various countries in the world. So far 144 countries are supported(Worldwide holidays library).

The validation and parsing of date are done without timezone and dates without times.

Usage

npm i business-date-checker

Features

  • Checking whether a date is a business date in a given country. Business date is a date that is not a holiday nor a weekend day
  • Calculation of the number of week days between two dates. Week days Monday to Friday
  • Calculation of the number of weekend days between two dates. Weekend days Saturday and Sunday
  • Calculation of the number of holidays between two dates in a given country
  • Checking whether a given date is a week day.
  • Checking whether a given date in a country is a holiday
  • Checking whether a given date is a weekend day.
  • Addition of a number of business days to a given date in a country to get the next business date.

APIs

  • isBusinessDate(date: Date, countryCode: string): boolean : Check whether a given Javascript date is a business date for a given country. A business date is a working day. It means any day of the year that is not a holiday or a weekend day. It returns true when the date is a valid business date or false when it is not a valid business date. The countryCode is the ISO2 value of the country.

  • weekDaysBetween(start: Date, end: Date): number: Calculates the number of week days between two Javascript dates. If end comes before start, then this function will return a negative value. Week days are Monday through Friday.

  • weekendDaysBetween(start: Date, end: Date): number: Calculates the number of weekend days between two Javascript dates. If end comes before start, then this function will return a negative value. Weekend days are Saturday and Sunday.

  • holidaysBetween(start: Date, end: Date, countryCode: string): number : Calculates the number of holidays between two Javascript dates. If end comes before start, or country is not valid then this function will return -1. The countryCode is the ISO2 value of the country.

  • isWeekDay(date: Date): boolean: Checks whether a given Javascript date is a week day. Week days are Monday through Friday. This include days that are holidays.

  • isWeekendDay(date: Date): boolean: Checks whether a given Javascript date is a weekend day. Weekend days are Saturday and Sunday.

  • isHoliday(date: Date, countryCode: string): boolean: Checks whether a given Javascript date is a holiday in a given country. The countryCode is the ISO2 value of the country.

  • addBusinessDays(date: Date, amount: number, countryCode: string): any : Add business days to a javascript date in a given country. The actual date is return in the format dddd, MMMM Do YYYY. It skips weekend days and holidays in that country. If the country is invalid or the amount is less than 1 it will return undefined.

References

About

Help validate javascript dates whether there are business date, holidays, week days or weekend days.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published