Socket
Book a DemoInstallSign in
Socket

@date/independence-day

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@date/independence-day

Create Independence Day Date by year or test if a Date is Independence Day.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

@date/independence-day

Build Status npm version Coverage Status

Use with @date/holidays, create Independence Day Date by year, or test if a Date is Independence Day.

Has default info for holiday which can be overridden when loading it into a @date/holidays.

Install

npm install --save @date/independence-day

Usage

// 1. use package directly
const holiday = require('@date/independence-day')

// the `gen` function creates a Date by year.
const date = holiday.gen(2001)

// the `is` function tests if a Date is the holiday.
const result = holiday.is(new Date(2001, 2, 3))

if (result) {
  // truthy value means it is a holiday.
}

// the actual returned value is a number between 0 and 3.
// 0 - not a holiday
// 1 - is a holiday on its main date in a year without an observed date.
// 2 - is a holiday on an observed date.
// 3 - is a holiday on its main date in a year with an observed date.


// 2. load into a @date/holidays instance:

// create a Holidays instance:
const holidays = require('@date/holidays')()

// load holiday into the Holidays instance:
// 1. without options overrides
holidays.load('@date/independence-day')
// 2. with options overrides:
holidays.load('@date/independence-day', {
  // optional override options here.
})

holidays.isHoliday(date)                 // true
holidays.isHoliday(new Date(2001, 0, 0)) // false

holidays.getHoliday(date)                 // array with info
holidays.getHoliday(new Date(2001, 0, 1)) // returns empty array

MIT License

Keywords

independence day

FAQs

Package last updated on 29 Jul 2019

Did you know?

Socket

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.

Install

Related posts