Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ods-holidays
Advanced tools
API for calculating correct past and future dates of government recognized holidays in Ontario
require('ods-holidays')
When you require ods-holidays
within your project you have access to two functions.
holidaysList(year)
This function takes any year past, present, or future as it's sole argument and returns an array of objects containing all public holidays for that year.
ex: holidays.holidaysList(1999)
would return:
[
{
date: "01-01-1999",
english: "New Year\'s Day",
french: "Jour de l\'An",
type: "federal",
stat: true
},
{
date: "02-15-1999",
english: "Family Day",
french: "Journée Familiale",
type: "provincial",
stat: true
},
{
date: "04-02-1999",
english: "Good Friday",
french: "Vendredi saint",
type: "federal",
stat: true
},
{
date: "04-05-1999",
english: "Easter Monday",
french: "Lundi de Pâques",
type: "provincial",
stat: false
},
{
date: "05-24-1999",
english: "Victoria Day",
french: "Fête de Victoria",
type: "federal",
stat: true
},
{
date: "07-01-1999",
english: "Canada Day",
french: "Fête du Canada",
type: "federal",
stat: true
},
{
date: "08-02-1999",
english: "Civic Holiday",
french: "Premier lundi d\'août",
type: "provincial",
stat: false
},
{
date: "09-06-1999",
english: "Labour Day",
french: "Fête du travail",
type: "federal",
stat: true
},
{
date: "10-11-1999",
english: "Thanksgiving",
french: "Action de grâce",
type: "federal",
stat: true
},
{
date: "11-11-1999",
english: "Remembrance Day",
french: "Jour du Souvenir",
type: "federal",
stat: false
},
{
date: "12-25-1999",
english: "Christmas Day",
french: "Noël",
type: "federal",
stat: true,
serviceHoliday: "12-27-1999"
},
{
date: "12-26-1999",
english: "Boxing Day",
french: "Lendemain de Noël",
type: "provincial",
stat: true,
serviceHoliday: "12-28-1999"
},
]
Occassionaly there is an additional property added to any holiday object of serviceHoliday
. This returns a date for which government services are unavailable. This occurs when the offical date of the holiday falls on a Saturday or a Sunday.
In our above example both Christmas and Boxing Day have this property. This is because in 1999 Christmas and Boxing Day occurred on Saturday and Sunday respectively. So government services would be unavailable on the 27th and 28th.
isHoliday(date)
This function is currently used to return whether a given date (in the format MM-DD-YYYY) is a government holiday. This informs services that government offices et al would be closed on these dates.
It will run the function for a given month and if the given date matches the returned date OR the serviceHoliday date (if it exists) then it will return {isHoliday: true}
, otherwise it returns {isHoliday: false}
.
npm test
will run through all the tests in this project using the node_modules mocha/chai.
If you want to run a specific set of tests you will need to make sure that mocha is installed globally.
npm install mocha -g
With this installed, mocha test
will run all the tests and using the -g flag will look for tests with the given string argument. For example
mocha -g 'Holiday Controller'
will run all the tests with Holiday Controller in the describe blocks.
The project mainly follows the google javascript standards with a few modifications. Filenames are camelcase when required and there is a soft limit of 80 chars and a hard limit of 120 chars for non test code. There is also a .eslintrc file that can be hooked into text editors and ide's to get them to follow our standard.
The preferred way to create new files is to use the following format
{resource_name}.{module_type}.js
However if you are working with files named with camelCase, please use that style for those resources.
So as an example, let us use holiday as an example.
The preferred way would look like:
holiday.view.js
hoiday.controller.js
All test files must be placed in the test
folder. Test files append .test
before the .js
so a test for the model would be:
holiday.model.test.js
FAQs
API for calculating correct past and future dates of government recognized holidays in Ontario
The npm package ods-holidays receives a total of 1 weekly downloads. As such, ods-holidays popularity was classified as not popular.
We found that ods-holidays demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.