Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

holidays-cs

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holidays-cs - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

56

dist/easter.js

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEasterDayName = exports.isHolyWeek = exports.getHollyWeekInterval = exports.isGoodFriday = exports.getGoodFriday = exports.isHolySaturday = exports.getHolySaturday = exports.isEasterSunday = exports.getEasterSunday = exports.getEaster = exports.isEasterMonday = exports.getEasterMonday = void 0;
const luxon_1 = require("luxon");
import { DateTime, Interval } from "luxon";
/**

@@ -9,6 +6,5 @@ * Returns the date of Easter Monday for a given year.

*/
function getEasterMonday(year) {
export function getEasterMonday(year) {
return getEaster(year).plus({ days: 1 });
}
exports.getEasterMonday = getEasterMonday;
/**

@@ -18,6 +14,5 @@ * Returns true if the given date is Easter Monday.

*/
function isEasterMonday(date) {
export function isEasterMonday(date) {
return date.equals(getEasterMonday(date.year));
}
exports.isEasterMonday = isEasterMonday;
/**

@@ -28,6 +23,5 @@ * Returns the date of Easter for a given year.

*/
function getEaster(year) {
export function getEaster(year) {
return getEasterSunday(year);
}
exports.getEaster = getEaster;
/**

@@ -37,3 +31,3 @@ * Returns the date of Easter for a given year.

*/
function getEasterSunday(year) {
export function getEasterSunday(year) {
let a = year % 19;

@@ -53,5 +47,4 @@ let b = Math.floor(year / 100);

let day = ((h + l - 7 * m + 114) % 31) + 1;
return luxon_1.DateTime.fromObject({ year, month, day });
return DateTime.fromObject({ year, month, day });
}
exports.getEasterSunday = getEasterSunday;
/**

@@ -61,7 +54,6 @@ * Returns true if the given date is Easter Sunday.

*/
function isEasterSunday(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isEasterSunday(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.equals(getEasterSunday(date.year));
}
exports.isEasterSunday = isEasterSunday;
/**

@@ -71,6 +63,5 @@ * Returns the date of Holy Saturday for a given year.

*/
function getHolySaturday(year) {
export function getHolySaturday(year) {
return getEaster(year).minus({ days: 1 });
}
exports.getHolySaturday = getHolySaturday;
/**

@@ -80,7 +71,6 @@ * Returns true if the given date is Holy Saturday.

*/
function isHolySaturday(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isHolySaturday(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.equals(getHolySaturday(date.year));
}
exports.isHolySaturday = isHolySaturday;
/**

@@ -90,6 +80,5 @@ * Returns the date of Good Friday for a given year.

*/
function getGoodFriday(year) {
export function getGoodFriday(year) {
return getEaster(year).minus({ days: 2 });
}
exports.getGoodFriday = getGoodFriday;
/**

@@ -99,7 +88,6 @@ * Returns true if the given date is Good Friday.

*/
function isGoodFriday(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isGoodFriday(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.equals(getGoodFriday(date.year));
}
exports.isGoodFriday = isGoodFriday;
/**

@@ -110,9 +98,8 @@ * Return the Interval of Holly Week for a given year.

*/
function getHollyWeekInterval(year) {
export function getHollyWeekInterval(year) {
let easter = getEaster(year);
return luxon_1.Interval.fromDateTimes(easter.minus({ days: 7 }), // Palm Sunday
return Interval.fromDateTimes(easter.minus({ days: 7 }), // Palm Sunday
easter.plus({ days: 1 }) // Easter Monday
);
}
exports.getHollyWeekInterval = getHollyWeekInterval;
/**

@@ -122,4 +109,4 @@ * Returns true if the given date is part of Holy Week.

*/
function isHolyWeek(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isHolyWeek(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
const interval = getHollyWeekInterval(date.year);

@@ -130,3 +117,2 @@ if (!interval.isValid)

}
exports.isHolyWeek = isHolyWeek;
/**

@@ -150,9 +136,9 @@ * Names of the days in Holy Week.

*/
function getEasterDayName(date) {
export function getEasterDayName(date) {
if (isHolyWeek(date)) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
const index = date.diff(getEaster(date.year), 'days').as('days');
return index in names ? names[index] : undefined;
}
return undefined;
}
exports.getEasterDayName = getEasterDayName;

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isFathersDay = exports.getFathersDay = void 0;
const luxon_1 = require("luxon");
import { DateTime } from 'luxon';
/**

@@ -10,4 +7,4 @@ * Get the date of Father's (Third Sunday in June) for the given year.

*/
function getFathersDay(year) {
return luxon_1.DateTime.fromObject({ year, month: 6, day: 1 })
export function getFathersDay(year) {
return DateTime.fromObject({ year, month: 6, day: 1 })
.plus({ weeks: 2 })

@@ -17,3 +14,2 @@ .startOf('week')

}
exports.getFathersDay = getFathersDay;
/**

@@ -24,6 +20,5 @@ * Is the given date Father's Day?

*/
function isFathersDay(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isFathersDay(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.equals(getFathersDay(date.year));
}
exports.isFathersDay = isFathersDay;

@@ -14,3 +14,3 @@ import { DateTime } from "luxon";

interface DayMetadata {
names: string[];
names: string[] | undefined;
isSignificantDay: boolean;

@@ -17,0 +17,0 @@ significantDay: string | undefined;

@@ -1,10 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDayMeta = void 0;
const luxon_1 = require("luxon");
const names_js_1 = require("./names.js");
const holidays_js_1 = require("./holidays.js");
const significant_js_1 = require("./significant.js");
const shops_js_1 = require("./shops.js");
const easter_js_1 = require("./easter.js");
import { DateTime } from "luxon";
import { getNameDayArray } from "./names.js";
import { isPublicHoliday, getPublicHoliday } from "./holidays.js";
import { getSignificantDay, isSignificantDay } from "./significant.js";
import { areShopsOpen, getShopsStatus } from "./shops.js";
import { getEasterDayName, isEasterMonday, isEasterSunday, isGoodFriday, isHolySaturday, isHolyWeek } from "./easter.js";
/**

@@ -14,28 +11,28 @@ * Get metadata for a specific day

*/
function getDayMeta(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function getDayMeta(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
let easter = undefined;
if ((0, easter_js_1.isHolyWeek)(date)) {
if (isHolyWeek(date)) {
easter = {
name: (0, easter_js_1.getEasterDayName)(date),
isGoodFriday: (0, easter_js_1.isGoodFriday)(date),
isHolySaturday: (0, easter_js_1.isHolySaturday)(date),
ieEasterSunday: (0, easter_js_1.isEasterSunday)(date),
isEasterMonday: (0, easter_js_1.isEasterMonday)(date),
name: getEasterDayName(date),
isGoodFriday: isGoodFriday(date),
isHolySaturday: isHolySaturday(date),
ieEasterSunday: isEasterSunday(date),
isEasterMonday: isEasterMonday(date),
};
}
let shops = {
areOpen: (0, shops_js_1.areShopsOpen)(date),
status: (0, shops_js_1.getShopsStatus)(date)
areOpen: areShopsOpen(date),
status: getShopsStatus(date)
};
return {
names: (0, names_js_1.getNameDayArray)(date),
names: getNameDayArray(date),
// easter metadata
easter: easter,
// national significant days
isSignificantDay: (0, significant_js_1.isSignificantDay)(date),
significantDay: (0, significant_js_1.getSignificantDay)(date),
isSignificantDay: isSignificantDay(date),
significantDay: getSignificantDay(date),
// national holidays
isPublicHoliday: (0, holidays_js_1.isPublicHoliday)(date),
publicHoliday: (0, holidays_js_1.getPublicHoliday)(date),
isPublicHoliday: isPublicHoliday(date),
publicHoliday: getPublicHoliday(date),
// shops metadata

@@ -45,2 +42,1 @@ shops: shops

}
exports.getDayMeta = getDayMeta;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPublicHoliday = exports.isPublicHoliday = void 0;
const luxon_1 = require("luxon");
const easter_js_1 = require("./easter.js");
import { DateTime } from "luxon";
import { isEasterMonday, isGoodFriday } from "./easter.js";
const holidays = {

@@ -23,7 +20,6 @@ "0101": "Den obnovy samostatného českého státu",

*/
function isPublicHoliday(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
return (0, easter_js_1.isEasterMonday)(date) || (0, easter_js_1.isGoodFriday)(date) || date.toFormat('ddMM') in holidays;
export function isPublicHoliday(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return isEasterMonday(date) || isGoodFriday(date) || date.toFormat('ddMM') in holidays;
}
exports.isPublicHoliday = isPublicHoliday;
/**

@@ -33,8 +29,8 @@ * Get the name of the holiday for the given date

*/
function getPublicHoliday(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
if ((0, easter_js_1.isEasterMonday)(date)) {
export function getPublicHoliday(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
if (isEasterMonday(date)) {
return "Velikonoční pondělí";
}
if ((0, easter_js_1.isGoodFriday)(date)) {
if (isGoodFriday(date)) {
return "Velký pátek";

@@ -44,2 +40,1 @@ }

}
exports.getPublicHoliday = getPublicHoliday;

@@ -1,24 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./easter.js"), exports);
__exportStar(require("./holidays.js"), exports);
__exportStar(require("./fathers-day.js"), exports);
__exportStar(require("./mothers-day.js"), exports);
__exportStar(require("./names.js"), exports);
__exportStar(require("./significant.js"), exports);
__exportStar(require("./shops.js"), exports);
__exportStar(require("./get-meta.js"), exports);
export * from "./easter.js";
export * from "./holidays.js";
export * from "./fathers-day.js";
export * from "./mothers-day.js";
export * from "./names.js";
export * from "./significant.js";
export * from "./shops.js";
export * from "./get-meta.js";

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMothersDay = exports.getMothersDay = void 0;
const luxon_1 = require("luxon");
import { DateTime } from 'luxon';
/**

@@ -10,4 +7,4 @@ * Get the date of Mother's (Second Sunday in May) for the given year.

*/
function getMothersDay(year) {
return luxon_1.DateTime.fromObject({ year, month: 5, day: 1 })
export function getMothersDay(year) {
return DateTime.fromObject({ year, month: 5, day: 1 })
.plus({ weeks: 1 })

@@ -17,3 +14,2 @@ .startOf('week')

}
exports.getMothersDay = getMothersDay;
/**

@@ -24,6 +20,5 @@ * Check if date is Mother's Day.

*/
function isMothersDay(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isMothersDay(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.equals(getMothersDay(date.year));
}
exports.isMothersDay = isMothersDay;

@@ -12,2 +12,2 @@ import { DateTime } from "luxon";

*/
export declare function getNameDayArray(date: DateTime | Date): string[];
export declare function getNameDayArray(date: DateTime | Date): string[] | undefined;

@@ -1,10 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameDayArray = exports.getNameDay = void 0;
const names_json_1 = __importDefault(require("./names.json"));
const luxon_1 = require("luxon");
const names = names_json_1.default;
import data from './names.json';
import { DateTime } from "luxon";
const names = data;
/**

@@ -15,7 +9,6 @@ * Get names as a string for the given date

*/
function getNameDay(date, joinWith = ' a ') {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
return getNameDayArray(date).join(joinWith);
export function getNameDay(date, joinWith = ' a ') {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return getNameDayArray(date)?.join(joinWith) || '';
}
exports.getNameDay = getNameDay;
/**

@@ -25,7 +18,6 @@ * Get the names of the name day for the given date

*/
function getNameDayArray(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function getNameDayArray(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
const day = date.toFormat('ddMM');
return day in names ? names[day] : [];
}
exports.getNameDayArray = getNameDayArray;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.areShopsOpen = exports.getShopsStatus = void 0;
const luxon_1 = require("luxon");
const easter_js_1 = require("./easter.js");
import { DateTime } from "luxon";
import { isEasterMonday } from "./easter.js";
/**

@@ -22,6 +19,6 @@ * List of days when the shop is closed.

*/
function getShopsStatus(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function getShopsStatus(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
// Easter Monday
if ((0, easter_js_1.isEasterMonday)(date)) {
if (isEasterMonday(date)) {
return "zavřeno";

@@ -36,3 +33,2 @@ }

}
exports.getShopsStatus = getShopsStatus;
/**

@@ -42,6 +38,5 @@ * Returns true if the given date is a shop open day.

*/
function areShopsOpen(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function areShopsOpen(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return getShopsStatus(date).startsWith("otevřeno");
}
exports.areShopsOpen = areShopsOpen;

@@ -6,3 +6,3 @@ import { DateTime } from "luxon";

*/
export declare function getSignificantDay(date: DateTime | Date): string;
export declare function getSignificantDay(date: DateTime | Date): string | undefined;
/**

@@ -9,0 +9,0 @@ * Returns true if the given date is a significant day.

@@ -1,10 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSignificantDay = exports.getSignificantDay = void 0;
const significant_json_1 = __importDefault(require("./significant.json"));
const luxon_1 = require("luxon");
const significant = significant_json_1.default;
import data from './significant.json';
import { DateTime } from "luxon";
const significant = data;
/**

@@ -14,7 +8,6 @@ * Returns the significant day for the given date.

*/
function getSignificantDay(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function getSignificantDay(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return significant[date.toFormat('ddMM')];
}
exports.getSignificantDay = getSignificantDay;
/**

@@ -24,6 +17,5 @@ * Returns true if the given date is a significant day.

*/
function isSignificantDay(date) {
date = date instanceof Date ? luxon_1.DateTime.fromJSDate(date) : date;
export function isSignificantDay(date) {
date = date instanceof Date ? DateTime.fromJSDate(date) : date;
return date.toFormat('ddMM') in significant;
}
exports.isSignificantDay = isSignificantDay;
{
"name": "holidays-cs",
"version": "0.0.5",
"author": "Roman Ožana <roman@ozana.cz> (https://ozana.cz)",

@@ -8,8 +9,15 @@ "repository": "git@github.com:OzzyCzech/holidays-cs.git",

"type": "module",
"exports": {
"types": "./dist/source/index.d.ts",
"default": "./dist/source/index.js"
},
"scripts": {
"build": "tsc",
"ava": "ava",
"ava": "NODE_OPTIONS='--import=tsx/esm' ava",
"xo": "xo *.js",
"test": "ava && xo"
"test": "xo && tsc --noEmit && ava"
},
"engines": {
"node": ">=20"
},
"main": "dist/index.js",

@@ -28,2 +36,3 @@ "types": "dist/index.d.ts",

"tsimp": "^2.0.11",
"tsx": "^4.7.2",
"typescript": "^5.4.5",

@@ -33,2 +42,3 @@ "xo": "^0.58.0"

"ava": {
"timeout": "1m",
"extensions": {

@@ -38,11 +48,10 @@ "ts": "module"

"files": [
"test/**/*.ts"
"test/*"
],
"workerThreads": false,
"nodeArguments": [
"--experimental-json-modules",
"--no-warnings",
"--import=tsimp"
"--no-warnings"
]
},
"version": "0.0.4"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc