Socket
Socket
Sign inDemoInstall

nyse-holidays

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.1.1

lib/common/util.js.map

1

lib/common/util.js

@@ -44,1 +44,2 @@ "use strict";

exports.getGoodFriday = getGoodFriday;
//# sourceMappingURL=util.js.map

@@ -21,25 +21,33 @@ "use strict";

var getHolidays = function (year) {
return [
{ name: "New Years Day", date: util_1.getDate({ year: year, month: 1, day: 1 }) },
{
name: "Martin Luther King, Jr. Day",
date: util_1.getNthDay({ n: 3, year: year, month: 1, day: 1 }),
},
{
name: "Washington's Birthday",
date: util_1.getNthDay({ n: 3, year: year, month: 2, day: 1 }),
},
{
name: "Good Friday",
date: util_1.getGoodFriday({ year: year }),
},
{ name: "Memorial Day", date: util_1.getLastDay({ year: year, month: 5, day: 1 }) },
{ name: "Independence Day", date: util_1.getDate({ year: year, month: 7, day: 4 }) },
{ name: "Labor Day", date: util_1.getNthDay({ n: 1, year: year, month: 9, day: 1 }) },
{
name: "Thanksgiving Day",
date: util_1.getNthDay({ n: 4, year: year, month: 11, day: 4 }),
},
{ name: "Christmas Day", date: util_1.getDate({ year: year, month: 12, day: 25 }) },
]
if (year < 1885) {
return [];
}
var holidays = [];
var newYearsDay = NewYearsDay(year);
newYearsDay && holidays.push(newYearsDay);
var martinLutherKingJrDay = MartinLutherKingJrDay(year);
martinLutherKingJrDay && holidays.push(martinLutherKingJrDay);
var lincolnsBirthday = LincolnsBirthday(year);
lincolnsBirthday && holidays.push(lincolnsBirthday);
var washingtonsBirthday = WashingtonsBirthday(year);
washingtonsBirthday && holidays.push(washingtonsBirthday);
var goodFriday = GoodFriday(year);
goodFriday && holidays.push(goodFriday);
var memorialDay = MemorialDay(year);
memorialDay && holidays.push(memorialDay);
var independenceDay = IndependenceDay(year);
independenceDay && holidays.push(independenceDay);
var laborDay = LaborDay(year);
laborDay && holidays.push(laborDay);
var columbusDay = ColumbusDay(year);
columbusDay && holidays.push(columbusDay);
var electionDay = ElectionDay(year);
electionDay && holidays.push(electionDay);
var veteransDay = VeteransDay(year);
veteransDay && holidays.push(veteransDay);
var thanksgivingDay = ThanksgivingDay(year);
thanksgivingDay && holidays.push(thanksgivingDay);
var christmasDay = ChristmasDay(year);
christmasDay && holidays.push(christmasDay);
var result = holidays
.map(function (holiday) {

@@ -49,13 +57,18 @@ if (holiday.date.day() === 0) {

}
else if (holiday.date.day() === 6) {
return __assign(__assign({}, holiday), { date: holiday.date.subtract(1, "day") });
if (holiday.date.day() === 6) {
var observed = holiday.date.subtract(1, "day");
if (holiday.date.isBefore(util_1.getDate({ year: 1959, month: 7, day: 3 }))) {
return __assign(__assign({}, holiday), { date: observed });
}
else if (observed.month() === holiday.date.month()) {
return __assign(__assign({}, holiday), { date: observed });
}
}
else {
return holiday;
}
return holiday;
})
.filter(function (holiday) { return holiday.date.year() === year; })
.filter(function (holiday) { return holiday.date.day() !== 6; })
.map(function (holiday) {
return __assign(__assign({}, holiday), { date: holiday.date.toDate(), dateString: holiday.date.format("YYYY-MM-DD") });
});
return result;
};

@@ -65,4 +78,110 @@ exports.getHolidays = getHolidays;

var year = dayjs_1.default(date).year();
return exports.getHolidays(year).some(function (holiday) { return holiday.date.toDateString() === date.toDateString(); });
return (exports.getHolidays(year).some(function (holiday) { return holiday.date.toDateString() === date.toDateString(); }) ||
exports.getHolidays(year + 1).some(function (holiday) { return holiday.date.toDateString() === date.toDateString(); }));
};
exports.isHoliday = isHoliday;
function NewYearsDay(year) {
return { name: "New Years Day", date: util_1.getDate({ year: year, month: 1, day: 1 }) };
}
function MartinLutherKingJrDay(year) {
if (year >= 1998) {
return {
name: "Martin Luther King, Jr. Day",
date: util_1.getNthDay({ n: 3, year: year, month: 1, day: 1 }),
};
}
}
function LincolnsBirthday(year) {
if (year >= 1896 && year <= 1953) {
return {
name: "Lincoln's Birthday",
date: util_1.getDate({ year: year, month: 2, day: 12 }),
};
}
}
function WashingtonsBirthday(year) {
var name = "Washington's Birthday";
if (year > 1971) {
return {
name: name,
date: util_1.getNthDay({ n: 3, year: year, month: 2, day: 1 }),
};
}
return {
name: name,
date: util_1.getDate({ year: year, month: 2, day: 22 }),
};
}
function GoodFriday(year) {
if (year === 1898 || year === 1906 || year === 1907) {
return undefined;
}
return {
name: "Good Friday",
date: util_1.getGoodFriday({ year: year }),
};
}
function MemorialDay(year) {
var name = "Memorial Day";
if (year >= 1971) {
return {
name: name,
date: util_1.getLastDay({ year: year, month: 5, day: 1 }),
};
}
else if (year >= 1873) {
return {
name: name,
date: util_1.getDate({ year: year, month: 5, day: 30 }),
};
}
}
function IndependenceDay(year) {
return {
name: "Independence Day",
date: util_1.getDate({ year: year, month: 7, day: 4 }),
};
}
function LaborDay(year) {
if (year >= 1887) {
return {
name: "Labor Day",
date: util_1.getNthDay({ n: 1, year: year, month: 9, day: 1 }),
};
}
}
function ColumbusDay(year) {
if (year >= 1909 && year <= 1953) {
return {
name: "Columbus Day",
date: util_1.getDate({ year: year, month: 10, day: 12 }),
};
}
}
function ElectionDay(year) {
if (year <= 1968 || year === 1972 || year === 1976 || year === 1980) {
var date = util_1.getNthDay({ n: 1, year: year, month: 11, day: 1 }).add(1, "day");
return {
name: "Election Day",
date: date,
};
}
}
function VeteransDay(year) {
if (year === 1918 || year === 1921 || (year >= 1934 && year <= 1953)) {
return {
name: "Veterans Day",
date: util_1.getDate({ year: year, month: 11, day: 11 }),
};
}
}
function ThanksgivingDay(year) {
return {
name: "Thanksgiving Day",
date: util_1.getNthDay({ n: 4, year: year, month: 11, day: 4 }),
};
}
function ChristmasDay(year) {
return { name: "Christmas Day", date: util_1.getDate({ year: year, month: 12, day: 25 }) };
}
//# sourceMappingURL=index.js.map

13

package.json
{
"name": "nyse-holidays",
"version": "1.0.3",
"version": "1.1.1",
"description": "Get all NYSE markets observe U.S. holidays",

@@ -14,4 +14,5 @@ "main": "lib/index.js",

"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.10",
"@types/tap": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^4.29.0",

@@ -23,4 +24,6 @@ "@typescript-eslint/parser": "^4.29.0",

"eslint-plugin-prettier": "^3.4.0",
"mocha": "^9.0.3",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"tap": "^15.0.9",
"source-map-support": "^0.5.19",
"ts-node": "^10.1.0",

@@ -33,4 +36,4 @@ "typescript": "^4.3.5"

"format": "prettier --ignore-unknown --ignore-path '.gitignore' --write '**/*'",
"test": "tap --node-arg=--require=ts-node/register './src/index.test.ts'",
"posttest": "tap --coverage-report=text-lcov | codecov --pipe"
"test": "nyc mocha",
"posttest": "nyc report --reporter=text-lcov | codecov --pipe"
},

@@ -37,0 +40,0 @@ "keywords": [

# nyse-holidays
Get all NYSE markets observe U.S. holidays
Get all NYSE markets observe U.S. holidays since 1885
[![Node.js CI](https://github.com/tsekityam/nyse-holidays/actions/workflows/test.yml/badge.svg)](https://github.com/tsekityam/nyse-holidays/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/tsekityam/nyse-holidays/branch/main/graph/badge.svg?token=gZOvThQpTV)](https://codecov.io/gh/tsekityam/nyse-holidays)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftsekityam%2Fnyse-holidays.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftsekityam%2Fnyse-holidays?ref=badge_shield)

@@ -74,1 +75,9 @@ ## Installation

[CodeSandbox](https://codesandbox.io/s/ts-example-o8smc)
## References
- [HISTORY OF NEW YORK STOCK EXCHANGE HOLIDAYS](https://www.bcm-news.de/wp-content/uploads/closings-nyse.pdf)
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftsekityam%2Fnyse-holidays.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftsekityam%2Fnyse-holidays?ref=badge_large)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc