Skip to content

JS library for operations with days, weeks, months and years. Configure weekends and holidays.

License

Notifications You must be signed in to change notification settings

vasanthps/calendar-ops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calendar-ops

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-ops';

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);

About

JS library for operations with days, weeks, months and years. Configure weekends and holidays.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published