npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ods-holidays

v1.0.7

Published

API for calculating correct past and future dates of government recognized holidays in Ontario

Downloads

5

Readme

Ontario Digital Serice Public Holidays Calulator

Setup

Getting Started

require('ods-holidays')

How the library works

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 return {isHoliday: true} if the given date is a holiday or a service holiday, otherwise it returns {isHoliday: false}.

Running tests

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.

Contributing:

Coding Standards

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.

Filenames

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

License

This project is governed by The Open Government License - Ontario

Found Here