Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dayjs-banking-days

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dayjs-banking-days

This is a Day.js plugin that is meant to provide efficient ways for getting US banking days.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by533.33%
Maintainers
1
Weekly downloads
 
Created
Source

dayjs-banking-days

This is a Day.js plugin that is meant to provide efficient ways for getting US banking days.

  • Inspired by moment-holiday and moment-business-days intended for common US banking holidays

Installation

Install via Bun, Yarn or NPM

bun add dayjs-banking-days
yarn add dayjs-banking-days
npm install dayjs-banking-days

Usage

By default, this plugin considers the following holidays:

  • New Year's Day
  • Martin Luther King Jr. Day
  • Presidents' Day
  • Memorial Day
  • Juneteenth
  • Independence Day
  • Labor Day
  • Veterans Day
  • Thanksgiving
  • Christmas

The following functionality is provided:

  • isBankingDay // Boolean
  • isBankingHoliday // Boolean
  • addBankingDays // dayjs.Dayjs
  • subtractBankingDays // dayjs.Dayjs
  • nextBankingDay // dayjs.Dayjs
  • previousBankingDay // dayjs.Dayjs

You will need to import the plugin and activate it via the Day.js .extend() function

import dayjs from 'dayjs'
import dayjsBankingDays from 'dayjs-banking-days'

dayjs.extend(dayjsBankingDays)

You can include custom dates by passing in an object that contains the one or both of the following properties:

  • fixedDateHolidays
  • floatingDateHolidays

Fixed date holidays always occur on the same date each year and are represent as a string with the format MM-DD, e.g. May 4th (Star Wars Day) would be 05-04. Floating date holidays occur on a specific day of the month, represented with an object comprised of the key being the month, an array where the first element is the day, followed by the occurence count in the month, e.g. Columbus Day is the 2nd Monday in October and would be represented { 10: [1, 2]}.

import dayjs from 'dayjs'
import dayjsBankingDays from 'dayjs-banking-days'

dayjs.extend(dayjsBankingDays, {
	fixedDateHolidays: ['05-04'],
	floatingDateHolidays: {
		10: [1, 2],
	},
})

To determine if it's a holiday

const isBankingDay: boolean = dayjs().isBankingDay()

To determine if it's a banking holiday

const isBankingHoliday: boolean = dayjs().isBankingHoliday()

To add banking days

const newDay: dayjs.Dayjs = dayjs().addBankingDays(2) // Adds 2 days

To subtract banking days

const newDay: dayjs.Dayjs = dayjs().subtractBankingDays(7) // Subtracts 7 days

Keywords

FAQs

Package last updated on 05 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc