Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
swedish-holidays-ts
Advanced tools
Typescript library for calculating the date of all swedish holidays for any given year.
Typescript port of swedish-holidays a library for calculating the date of all swedish holidays for any given year.
$ npm install swedish-holidays-ts
import {
getHolidays,
getUpcomingHolidays,
isHoliday,
isPublicHoliday,
} from "swedish-holidays";
// Get an array of all holidays for the current
const holidays = getHolidays();
// Get an array of all holidays for a specific year
const holidays2019 = getHolidays(2019);
// Get an array of all upcoming holidays
const upcoming = getUpcomingHolidays();
// Check if today is a holiday
const isItAHolidayToday = isHoliday();
// Or if you want to check a specific date
const isThisAHoliday = isHoliday(new Date("2019-12-24"));
// Check if today is a public holiday in Sweden (see https://www.riksdagen.se/sv/dokument-lagar/dokument/svensk-forfattningssamling/lag-1989253-om-allmanna-helgdagar_sfs-1989-253)
const isItAPublicHolidayToday = isPublicHoliday();
// Or if you want to check a specific date
const isThisAPublicHoliday = isPublicHoliday(new Date("2021-11-1"));
The result will always be an Array
filled with JSON formatted holiday information including name and date.
[
{
name: 'Julafton',
date: '2019-12-24T00:00:00.000Z',
day: 24,
month: 12,
year: 2019,
isPublicHoliday: false,
},
{
name: 'Juldagen',
date: '2019-12-25T00:00:00.000Z',
day: 25,
month: 12,
year: 2019,
isPublicHoliday: true,
},
...
]
When using isHoliday
the result is false
if the provided date is not a holiday, otherwise it is the holiday JSON object.
When using isPublicHoliday
the result is false
if the provided date is not a public holiday.
If you want the holiday names to be returned using a different language than the default (Swedish), use the language
JSON object and modify it before passing it to the getHolidays
function.
const { language } = require("swedish-holidays");
const translation = { ...language };
// This value is 'Julafton' by default.
translation.christmasEve = "Christmas Eve";
const holidays2019 = getHolidays(2019, translation);
// or if you want the current year
// supply a year that is 'falsy' e.g. undefined / null / 0 / false
const holidays = getHolidays(0, translation);
This library can only return valid holidays for years between 1582 and 8702.
If an invalid year is requested, some holidays will be missing.
FAQs
Typescript library for calculating the date of all swedish holidays for any given year.
The npm package swedish-holidays-ts receives a total of 0 weekly downloads. As such, swedish-holidays-ts popularity was classified as not popular.
We found that swedish-holidays-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.