calendar-ops

1.0.0 • Public • Published

calendar.js

Wrapper around momentjs for operations around days with configuration of weekends and holidays.

Usage

Install from npm

npm install calendar-ops --save

Import and create a new Calendar object

import Calendar from 'calendar';
 
let calendar = new Calendar();
 

Configure weekends / weekly holidays.

Defaults to Saturday and Sunday.

calendar.setWeeklyHolidays([5]);

This code sets weekly holidays to Fridays. Use array of numbers between 0 to 6 corresponding to Sunday thorugh Saturday.

Configure holidays

//Array of date objects / date strings
calendar.addHolidays([new Date("11/23/2017"),  new Date("11/24/2017")]);
 
//Date object / string
calendar.addHolidays(new Date("12/25/2017"));
 
//Date range - array of two date objects / strings corresponding to start date and end date
calendar.addHolidayRange([new Date("12/30/2017"), new Date("1/2/2018")]);
 

Start adding days

//Pass a date object / string and number of days to add
calendar.addDays(new Date("11/22/2017"), 10);

Package Sidebar

Install

npm i calendar-ops

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • vasanthps