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

@date/holidays-us

v0.4.0

Published

USA bank and (some) public holidays

Downloads

6,140

Readme

@date/holidays-us

Build Status npm version Coverage Status

A @date/holidays instance with USA public and bank holidays.

Also has functions to calculate dates for specific holidays.

Install

npm install @date/holidays-us --save

Usage

// get Holidays instance with both public and bank holidays
var holidays = require('@date/holidays-us')

var date = new Date(2016, 0, 1) // New Year's Day 2016
holidays.isHoliday(date) // true

date.setDate(10) // January 10th 2016
holidays.isHoliday(date) // false

date = holidays.thanksgiving(2015) // November 26th, 2015
date = holidays.thanksgiving(2016) // November 24th, 2016

date = holidays.valentinesDay(2016) // February 14th, 2016
holidays.isHoliday(date) // true, it's a holiday

// this will return false because Valentine's Day isn't a bank holiday
holidays.isHoliday(date, {
  // only consider it a holiday when the properties in this object match
  bank:true // must be a bank holiday
})

Only Bank Holidays

// this has only the bank holidays, not the 'public' ones
var holidays = require('@date/holidays-us').bank()

// returns false, Valentine's isn't a bank holiday
holidays.isHoliday(new Date(2016, 1, 14))

// returns true, New Year's is a bank holiday
holidays.isHoliday(new Date(2016, 0, 1))

Only Public Holidays

// this has only the non-bank holidays
var holidays = require('@date/holidays-us').public()

// returns true, Valentine's is a public holiday
holidays.isHoliday(new Date(2016, 1, 14))

// returns false, because New Year's is a bank holiday
holidays.isHoliday(new Date(2016, 0, 1))

// NOTE: technically, I suppose the bank holidays are also
// public holidays, but, if you want both, use the default
// instance which has both

API: Generators

Functions which generate a specific holiday based on a specified year:

  1. newYearsDay() - can calculate observed holiday as well
  2. valentinesDay()
  3. martinLutherKingDay()
  4. presidentsDay()
  5. easter()
  6. mothersDay()
  7. memorialDay()
  8. fathersDay()
  9. independenceDay() - can calculate observed holiday as well
  10. laborDay()
  11. columbusDay()
  12. halloween()
  13. veteransDay() - can calculate observed holiday as well
  14. thanksgiving()
  15. christmas() - can calculate observed holiday as well

API: Observed Holidays

Some holidays are "observed" on a different day than the holiday. The generate functions can calculate that as well.

var holidays = require('@date/holidays-us')

// Christmas in 2016 is on a Sunday so it is "observed" the next day, Monday.
// the call to the generator returns the date instance as expected
var christmasDay = holidays.christmas(2016) // same as new Date(2016, 11, 25)
// it also has an `observed` property containing the "observed" holiday date
// Note: if there is no "observed" holiday then `observed` is undefined
var observedChristmas = date.observed

// christmas         == new Date(2016, 11, 25) Sunday, December 25th 2016
// observedChristmas == new Date(2016, 11, 26) Monday, December 26th 2016

MIT License