New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

moment-business-days

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-business-days

MomentJS plugin to use business days

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
97K
decreased by-32.12%
Maintainers
4
Weekly downloads
 
Created

What is moment-business-days?

The moment-business-days npm package extends the Moment.js library to handle business days calculations. It allows you to perform operations like adding or subtracting business days, checking if a date is a business day, and customizing business days and holidays.

What are moment-business-days's main functionalities?

Add Business Days

This feature allows you to add a specified number of business days to a date. In this example, 5 business days are added to October 1, 2023.

const moment = require('moment-business-days');
let date = moment('2023-10-01');
let newDate = date.businessAdd(5);
console.log(newDate.format('YYYY-MM-DD'));

Subtract Business Days

This feature allows you to subtract a specified number of business days from a date. In this example, 3 business days are subtracted from October 10, 2023.

const moment = require('moment-business-days');
let date = moment('2023-10-10');
let newDate = date.businessSubtract(3);
console.log(newDate.format('YYYY-MM-DD'));

Check if a Date is a Business Day

This feature allows you to check if a given date is a business day. In this example, it checks if October 7, 2023, is a business day.

const moment = require('moment-business-days');
let date = moment('2023-10-07');
let isBusinessDay = date.isBusinessDay();
console.log(isBusinessDay);

Custom Business Days and Holidays

This feature allows you to customize the business days and holidays. In this example, it sets the working weekdays to Monday through Friday and adds holidays on December 25, 2023, and January 1, 2023. Then it adds 1 business day to December 24, 2023.

const moment = require('moment-business-days');
moment.updateLocale('us', {
  workingWeekdays: [1, 2, 3, 4, 5],
  holidays: ['2023-12-25', '2023-01-01'],
  holidayFormat: 'YYYY-MM-DD'
});
let date = moment('2023-12-24');
let newDate = date.businessAdd(1);
console.log(newDate.format('YYYY-MM-DD'));

Other packages similar to moment-business-days

Keywords

FAQs

Package last updated on 16 Apr 2020

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