calendario
Check if a day is a workday or holiday.
Available too: brazilian portuguese.
Install
Before anything, you need to have node and npm installed.
$ npm install calendario
Usage
Currently there are only national calendars (except for Brazil and U.S.A). In next release will be added regional support.
Available for:
- Brazil
.use('BR')
- United States of America
.use('US')
You can set the calendar using use()
var calendario = ;calendario;
Setting the calendar for a specific state
var calendario = ;calendario;
You can create your owns calendars, passing a array of objects like these:
var calendario = ; calendario; calendario;
You can create your own calendar, passing a ics
file
var calendario = ;calendario;
Methods
isWorkday
Verify if the day in question is a working day, based on defined calendar sources:
var calendario = ;calendario; calendario; // falsecalendario; // true
aboutDay
Get all events about specified day:
var calendario = ;calendario; calendario/*[ { date: Fri Dec 25 2015 00:00:00 GMT-0200 (BRST), summary: 'Christmas Day', workday: false } ]*/
range
Get all events from a specified begin to a specified end:
var calendario = ;calendario; var range = calendario ; /*[ { date: Thu Dec 24 2015 00:00:00 GMT-0200 (BRST), summary: 'Christmas Eve (from 2pm)', workday: false }, { date: Fri Dec 25 2015 00:00:00 GMT-0200 (BRST), summary: 'Christmas Day', workday: false }, { date: Thu Dec 31 2015 00:00:00 GMT-0200 (BRST), summary: 'New Year\'s Eve (from 2pm)', workday: false }, { date: Fri Jan 01 2016 00:00:00 GMT-0200 (BRST), summary: 'New Year\'s Day', workday: false } ]*/
sourceList
Return all defined calendars as source:
var calendario = ;calendario;calendario; calendario; // ['US', 'BR']
eventList
Return the events from all sources:
var calendario = ;calendario; calendario;/*[ { workday: true, summary: 'Mozilla Summit', date: Tue Nov 24 2020 22:00:00 GMT-0200 (BRST) }, { workday: true, summary: 'Mozilla another event', date: Wed Jan 20 2021 00:00:00 GMT-0200 (BRST) } ]*/
clear
Clear and remove all previously defined sources:
var calendario = ;calendario; // Sources: ['BR']calendarioclear; // Sources: []
ignoreWeekends
By default the calendario don't consider weekends as workdays. However you can change this using:
var calendario = ;calendario;
Data Source
Brazil
- National Events: Google Calendar; ID:
pt-br.brazilian#holiday@group.v.calendar.google.com
- Regional Events: Wikipedia
United States of America
- National Events: Google Calendar; ID:
en.usa#holiday@group.v.calendar.google.com
- Regional Events: Wikipedia
History
See Changelog for more details.
Contributing
Don't be shy, send a Pull Request! Here is how:
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
About
License: MIT ® Raphael Amorim