@itenium/date-holidays-be
Advanced tools
Comparing version 0.0.2 to 1.0.0
@@ -1,25 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isHoliday = exports.getHolidays = void 0; | ||
function getEaster(year) { | ||
var C = Math.floor(year / 100); | ||
var N = year - 19 * Math.floor(year / 19); | ||
var K = Math.floor((C - 17) / 25); | ||
var I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15; | ||
const C = Math.floor(year / 100); | ||
const N = year - 19 * Math.floor(year / 19); | ||
const K = Math.floor((C - 17) / 25); | ||
let I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15; | ||
I = I - 30 * Math.floor((I / 30)); | ||
I = I - Math.floor(I / 28) * (1 - Math.floor(I / 28) * Math.floor(29 / (I + 1)) * Math.floor((21 - N) / 11)); | ||
var J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4); | ||
let J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4); | ||
J = J - 7 * Math.floor(J / 7); | ||
var L = I - J; | ||
var M = 3 + Math.floor((L + 40) / 44); | ||
var D = L + 28 - 31 * Math.floor(M / 4); | ||
const L = I - J; | ||
const M = 3 + Math.floor((L + 40) / 44); | ||
const D = L + 28 - 31 * Math.floor(M / 4); | ||
return new Date(year, M - 1, D); | ||
} | ||
function getEasterMonday(year) { | ||
var easter = getEaster(year); | ||
var daysToMonday = ((7 - easter.getDay()) % 7 + 1) % 7; | ||
const easter = getEaster(year); | ||
const daysToMonday = ((7 - easter.getDay()) % 7 + 1) % 7; | ||
return new Date(easter.getFullYear(), easter.getMonth(), easter.getDate() + daysToMonday); | ||
} | ||
function getAscensionDay(year) { | ||
var date = new Date(getEaster(year)); | ||
let date = new Date(getEaster(year)); | ||
date.setDate(date.getDate() + 39); | ||
@@ -29,5 +26,5 @@ return date; | ||
function getWhitMonday(year) { | ||
var whitMonday = new Date(getAscensionDay(year)); | ||
let whitMonday = new Date(getAscensionDay(year)); | ||
whitMonday.setDate(whitMonday.getDate() + 9); | ||
var daysToMonday = ((7 - whitMonday.getDay()) % 7 + 1) % 7; | ||
const daysToMonday = ((7 - whitMonday.getDay()) % 7 + 1) % 7; | ||
whitMonday.setDate(whitMonday.getDate() + daysToMonday); | ||
@@ -37,3 +34,3 @@ return whitMonday; | ||
/** Get all official Belgian holidays in the provided year */ | ||
function getHolidays(year) { | ||
export function getHolidays(year) { | ||
return [ | ||
@@ -52,9 +49,8 @@ { date: new Date(year, 0, 1), labels: { nl: 'Nieuwjaar', fr: 'Nouvel An', de: 'Neujahr', en: 'New Year\'s Day' } }, | ||
} | ||
exports.getHolidays = getHolidays; | ||
/** Returns whether the provided Date is an official Belgian holiday */ | ||
function isHoliday(date) { | ||
export function isHoliday(date) { | ||
if (!date) { | ||
return false; | ||
} | ||
return getHolidays(date.getFullYear()).some(function (item) { | ||
return getHolidays(date.getFullYear()).some(item => { | ||
return item.date.getDate() === date.getDate() && | ||
@@ -65,3 +61,1 @@ item.date.getMonth() === date.getMonth() && | ||
} | ||
exports.isHoliday = isHoliday; | ||
//# sourceMappingURL=belgianHolidays.js.map |
{ | ||
"name": "@itenium/date-holidays-be", | ||
"version": "0.0.2", | ||
"version": "1.0.0", | ||
"private": false, | ||
"description": "Package to determine the official Belgian holidays for a given year", | ||
"description": "Zero dependency functions to determine the official Belgian holidays for a given year in NL/FR/EN/DE", | ||
"homepage": "https://github.com/itenium-be/date-holidays-be", | ||
@@ -7,0 +7,0 @@ "bugs": { |
@@ -59,4 +59,8 @@ # date-holidays-be | ||
[`date-holidays-be` @ npmjs.com](https://www.npmjs.com/package/@itenium/date-holidays-be) | ||
```sh | ||
npm run build | ||
npm login # username: itenium | ||
npm publish --access public | ||
``` |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
66
6826
5
70