Socket
Socket
Sign inDemoInstall

swedish-holidays

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swedish-holidays - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

dist/date-utils.d.ts

88

package.json
{
"name": "swedish-holidays",
"version": "1.1.0",
"description": "Library for calculating the date of all swedish holidays for any given year.",
"main": "./dist/holidays.js",
"scripts": {
"build": "babel ./src --out-dir ./dist -s inline --delete-dir-on-start",
"prepack": "npm run build",
"test": "npm run build && jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Pythe1337N/swedish-holidays.git"
},
"keywords": [
"holiday",
"holidays",
"sweden",
"helger",
"helgdag",
"helgdagar",
"sverige"
],
"author": "Oskar Bernberg (Pythe1337N)",
"license": "MIT",
"files": [
"dist/*",
"examples/*"
],
"devDependencies": {
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"@babel/plugin-proposal-export-namespace-from": "^7.16.0",
"jest": "^27.3.1",
"pre-commit": "^1.2.2"
},
"precommit": "build",
"homepage": "https://github.com/Pythe1337N/swedish-holidays#readme",
"bugs": {
"url": "https://github.com/Pythe1337N/swedish-holidays/issues"
},
"runkitExampleFilename": "./examples/example.js"
"name": "swedish-holidays",
"version": "1.1.1",
"description": "Library for calculating the date of all swedish holidays for any given year.",
"main": "./dist/index.js",
"scripts": {
"build": "rm -rf ./dist && tsc",
"test": "node --loader tsx --test ./tests/*",
"prettier:all": "prettier --write ./src && prettier --write ./tests",
"pretty": "pretty-quick --staged",
"prepack": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Pythe1337N/swedish-holidays.git"
},
"keywords": [
"holiday",
"holidays",
"sweden",
"easter",
"helger",
"helgdag",
"helgdagar",
"sverige",
"påsk"
],
"author": "Oskar Bernberg (Pythe1337N)",
"license": "MIT",
"files": [
"dist/*",
"examples/*"
],
"devDependencies": {
"@types/node": "^18.11.17",
"pre-commit": "^1.2.2",
"prettier": "^2.8.1",
"pretty-quick": "^3.1.3",
"tsx": "^3.12.1",
"typescript": "^4.9.4"
},
"pre-commit": "pretty",
"homepage": "https://github.com/Pythe1337N/swedish-holidays#readme",
"bugs": {
"url": "https://github.com/Pythe1337N/swedish-holidays/issues"
},
"runkitExampleFilename": "./examples/example.js"
}
# swedish-holidays
Library for calculating the date of all swedish holidays for any given year.
## How to install:
```shell

@@ -10,10 +12,6 @@ $ npm install swedish-holidays

## How to use:
```js
const {
getHolidays,
getUpcomingHolidays,
isHoliday,
isPublicHoliday
} = require('swedish-holidays');
```ts
import { getHolidays, getUpcomingHolidays, isHoliday, isPublicHoliday } from 'swedish-holidays';
// Get an array of all holidays for the current

@@ -32,3 +30,3 @@ const holidays = getHolidays();

// Or if you want to check a specific date
const isThisAHoliday = isHoliday(new Date("2019-12-24"));
const isThisAHoliday = isHoliday(new Date('2019-12-24'));

@@ -39,5 +37,7 @@ // 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)

// Or if you want to check a specific date
const isThisAPublicHoliday = isPublicHoliday(new Date("2021-11-1"));
const isThisAPublicHoliday = isPublicHoliday(new Date('2021-11-01'));
```
The result will always be an ```Array``` filled with JSON formatted holiday information including name and date.
The result will always be an `Array` filled with JSON formatted holiday information including name and date.
```js

@@ -62,4 +62,5 @@ [

...
]
]
```
When using `isHoliday` the result is `false` if the provided date is not a holiday, otherwise it is the holiday JSON object.

@@ -69,4 +70,22 @@

## Using holidays directly
Each holiday is exported and can be used individually.
`IHolidayOptions` is used to pass parameters to the constructor.
Both year and localization is supported.
For convenience holidays may also be imported using their swedish names.
```ts
import { MidsummerEve, Midsommarafton } from 'swedish-holidays';
// Both will be equal instances of the same class
const midsummerA = new MidsummerEve({ year: 2022 });
const midsummerB = new Midsommarafton({ year: 2022 });
```
## Localization
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.
```js

@@ -82,31 +101,47 @@ const { language } = require('swedish-holidays');

const holidays = getHolidays(0, translation);
```
```
Or use the interface `IHolidayNames`
```ts
import { getHolidays, IHolidayNames } from 'swedish-holidays';
const language: IHolidayNames = {
...
christmasEve: 'Christmas Eve',
...
}
const holidays2019 = getHolidays(2019, language);
```
## Limitations
This library can only return valid holidays for years between 1582 and 8702.
If an invalid year is requested, some holidays will be missing.
If an invalid year is requested, an error will be thrown.
## Supported Holidays
* New Year's Day / Nyårsdagen
* Twelfth Night / Trettondagsafton
* Epiphany / Trettondedag jul
* Maundy Thursday / Skärtorsdagen
* Good Friday / Långfredagen
* Holy Saturday / Påskafton
* Easter Sunday / Påskdagen
* Easter Monday / Annandag påsk
* Walpurgis Night / Valborgsmässoafton
* May First / Första maj
* Ascension Day / Kristi himmelsfärdsdag
* Swedish National Day / Sveriges nationaldag
* Pentecost Eve / Pingstafton
* Whit Sunday / Pingstdagen
* Midsummer Eve / Midsommarafton
* Midsummer Day / Midsommardagen
* All Saints Eve / Allhelgonaafton
* All Saints Day / Alla helgons dag
* Christmas Eve / Julafton
* Christmas Day / Juldagen
* Boxing Day / Annandag jul
* New Years Eve / Nyårsafton
- New Year's Day / Nyårsdagen
- Twelfth Night / Trettondagsafton
- Epiphany / Trettondedag jul
- Maundy Thursday / Skärtorsdagen
- Good Friday / Långfredagen
- Holy Saturday / Påskafton
- Easter Sunday / Påskdagen
- Easter Monday / Annandag påsk
- Walpurgis Night / Valborgsmässoafton
- May First / Första maj
- Ascension Day / Kristi himmelsfärdsdag
- Swedish National Day / Sveriges nationaldag
- Pentecost Eve / Pingstafton
- Whit Sunday / Pingstdagen
- Midsummer Eve / Midsommarafton
- Midsummer Day / Midsommardagen
- All Saints Eve / Allhelgonaafton
- All Saints Day / Alla helgons dag
- Christmas Eve / Julafton
- Christmas Day / Juldagen
- Boxing Day / Annandag jul
- New Years Eve / Nyårsafton
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