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 🙏

© 2026 – Pkg Stats / Ryan Hefner

chrono-holidays

v0.0.7

Published

Holidays addition to `chrono`

Readme

chrono-holidays

pipeline status

An extension for chrono to provide parsing for holidays.

It knows things like thanksgiving in 2017 and christmas!

Usage

$ yarn add chrono-holidays

(or use npm, I'm not picky).

Then, from code (all examples here are es2015, but it works just as well in es5):

import chrono from 'chrono-holidays';

const xmas = chrono.parseDate('christmas');
// xmas is a Date object for December 25 of the current year

So you want even more holidays?

The object you get from importing chrono-holidays has an addHoliday method that accepts a holiday in the format in the json files. For example,

import chrono from 'chrono-holidays';
chrono.addHoliday({
    name: "robert'?s birthday",
    type: 'abs',
    month: 11,
    date: 5,
});

chrono.parseDate("robert's birthday", new Date(2018,1,1)).toDateString()
// returns 'Mon Nov 05 2018'

Why not merge into chrono?

I don't want people to have to install holidays if they don't care. I expect the JSON files will end up getting fairly large. This doesn't duplicate chrono though, just includes it and uses its excellent custom parser support.

Contributing

Commit yarn.lock, not package-lock.json. Add holidays. Fix bugs. As long as it passes tests, you're good to go and I'll almost certainly accept your MR.

Add at least one test for every new holiday by putting a json file in test/holidays/ that matches the format of the ones already there (or edit an existing file).

Holidays json files

There are two types of holidays.

Relative ("type": "rel") holidays are like Thanksgiving, the fourth Thursday of November. That is, it is identified by a month, day of week, and week count. Day of week is indexed with 0 for Sunday, the same way JavaSCript's Date uses the day field. Months start with January at 1, and the first week of the month is "nth": 1. The last week of the month is "nth": -1.

Absolute holidays are like Christmas, December 25. They are identified by a month and date.

The name field is actually a regex. Slashes must be escaped twice, since it must be expressed as a string to be stored in JSON. However, it will be made case-insensitive, and all literal spaces will be replaced with /\s+/ to allow for any whitespace, so you shouldn't need many slashes if any. Do be aware that this means that a character class with a space won't work, because /[ +-]/ will expand to /[(?:\s+)+-]/ which is not at all what you want. In that case, use a capture group with an or: /( |[+-])/.

Test json files

The test json files are just an object with input strings (date-qualified) as the keys and expected dates parsable by new Date() as the values. Every entry will be tested against the custom parser.