Socket
Socket
Sign inDemoInstall

node-red-contrib-german-holidays

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2-beta

110

german-holidays.js

@@ -54,2 +54,23 @@ /********************************************

function _dateToString(d) {
// return d.getUTCFullYear() + '-' + _pad2(d.getUTCMonth() + 1) + '-' + _pad2(d.getUTCDate()) + 'T' + _pad2(d.getUTCHours()) + ':' + _pad2(d.getUTCMinutes()) + 'Z';
const date = new Date(d); // copy instance
const offset = date.getTimezoneOffset();
const h = Math.floor(Math.abs(offset) / 60);
const m = Math.abs(offset) % 60;
date.setMinutes(date.getMinutes() - offset); // apply custom timezone
return date.getUTCFullYear() + '-' // return custom format
+ _pad2(date.getUTCMonth() + 1) + '-'
+ _pad2(date.getUTCDate()) + 'T'
+ _pad2(date.getUTCHours()) + ':'
+ _pad2(date.getUTCMinutes()) + ':'
+ _pad2(date.getUTCSeconds())
+ (offset === 0 ? 'Z' : (offset < 0 ? '+' : '-') + _pad2(h) + ':' + _pad2(m));
}
/**
* Format a date do a string similar to ISO format, but with no secondy or milliseconds to be shorter
* @param {Date} d Date to format
* @returns {string} date representation
*/
function _dateToUTCString(d) {
return d.getUTCFullYear() + '-' + _pad2(d.getUTCMonth() + 1) + '-' + _pad2(d.getUTCDate()) + 'T' + _pad2(d.getUTCHours()) + ':' + _pad2(d.getUTCMinutes()) + 'Z';

@@ -59,2 +80,12 @@ }

/**
* formates a Date to a string (no time YYYY-MM-DD)
* @param {Date} d Date to format
* @returns {string} Date string in the format YYYY-MM-DD
* @private
*/
function _dateToDateString(d) {
return d.getFullYear() + '-' + _pad2(d.getMonth() + 1) + '-' + _pad2(d.getDate());
}
/**
* checks if a value is a valid Date object

@@ -72,4 +103,4 @@ * @param {*} d - a value to check

* @returns number current week number
*/
function _getWeekNumber(d) {
*
function _getUTCWeekNumber(d) {
// Copy date so don't modify original

@@ -81,2 +112,16 @@ d = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));

return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
} /* */
/**
* determinates the current week number of timestamp.
* @param d date for determinate week number
* @returns number current week number
*/
function _getWeekNumber(d) {
// Copy date so don't modify original
d = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 1);
const dayNum = d.getDay() || 7;
d.setDate(d.getDate() + 4 - dayNum);
const yearStart = new Date(d.getFullYear(), 0, 1);
return Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
}

@@ -88,5 +133,19 @@

* @param {*} ts the timestamp
*
function _checkUTCDefault(node, ts) {
const newYear = (new Date()).getUTCFullYear();
if (newYear !== node.default.year) {
node.default.ts = ts;
node.default.year = newYear;
node.default.dayObjs = _getSpecialDaysOfYear(node, node.default.year, true, true);
}
} /* */
/**
* check if default value could be used
* @param {*} node The Node object
* @param {*} ts the timestamp
*/
function _checkDefault(node, ts) {
const newYear = (new Date()).getUTCFullYear();
const newYear = (new Date()).getFullYear();
if (newYear !== node.default.year) {

@@ -187,3 +246,4 @@ node.default.ts = ts;

const D = L + 28 - 31 * Math.floor(M / 4);
return new Date(Date.UTC(year, M - 1, D));
// return new Date(Date.UTC(year, M - 1, D));
return new Date(year, M - 1, D);
}

@@ -212,3 +272,4 @@

function _firstNthWeekdayOfMonth(year, month, dayOfWeek, n) {
const date = new Date(Date.UTC(year, month, 1));
// const date = new Date(Date.UTC(year, month, 1));
const date = new Date(year, month, 1);
const add = (dayOfWeek - date.getDay() + 7) % 7 + n * 7;

@@ -228,3 +289,4 @@ date.setDate(1 + add);

function _lastNthWeekdayOfMonth(year, month, dayOfWeek, n) {
const date = new Date(Date.UTC(year, month + 1, 0));
// const date = new Date(Date.UTC(year, month + 1, 0));
const date = new Date(year, month + 1, 0);
const dy = date.getDay(); // day of week

@@ -248,3 +310,4 @@ if ( dy < dayOfWeek) {

if (typeof year === 'object') {
year = year.getUTCFullYear();
// year = year.getUTCFullYear();
year = year.getFullYear();
}

@@ -269,3 +332,4 @@

if (naturalMonthOrRef <= 12 && day >= 1 && day <= 31) {
return new Date(Date.UTC(year, naturalMonthOrRef - 1, day));
// return new Date(Date.UTC(year, naturalMonthOrRef - 1, day));
return new Date(year, naturalMonthOrRef - 1, day);
}

@@ -306,8 +370,10 @@ return null;

tsUTC: _toUtcTimestamp(date),
dateString: _localeDateObjectToDateString(date),
dateString: _dateToDateString(date),
dateTimeString: _dateToString(date),
dateUTCTimeString: _dateToUTCString(date),
dateISOString: date.toISOString(),
characteristics,
equals(date) {
const string = _localeDateObjectToDateString(date);
return this.dateString === string;
const str = _dateToDateString(date);
return this.dateString === str;
}

@@ -380,14 +446,2 @@ };

/**
*
* @param {Date} date
* @returns {string}
* @private
*/
function _localeDateObjectToDateString(date) {
date = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
date.setUTCHours(0, 0, 0, 0);
return date.toISOString().slice(0, 10);
}
/**
* Returns the UTC timestamp of the given date with hours, minutes, seconds, and milliseconds set to zero.

@@ -598,4 +652,4 @@ * @param {Date} date

// outMsg.data.year = outMsg.data.ts.getFullYear();
outMsg.data.year = outMsg.data.ts.getUTCFullYear();
// outMsg.data.year = outMsg.data.ts.getUTCFullYear();
outMsg.data.year = outMsg.data.ts.getFullYear();

@@ -619,3 +673,4 @@ // this.debug(JSON.stringify(outMsg, Object.getOwnPropertyNames(outMsg)));

outMsg.data.comment = 'data date';
outMsg.data.year = dto.getUTCFullYear();
// outMsg.data.year = dto.getUTCFullYear();
outMsg.data.year = dto.getFullYear();
const specialdays = _getSpecialDaysOfYear(this, outMsg.data.year);

@@ -637,3 +692,4 @@ outMsg.payload = this.getDataForDate(dto, specialdays, undefined, msg);

if (typeof outMsg.data.day !== 'undefined' || !isNaN(outMsg.data.day)) {
outMsg.data.year = outMsg.data.ts.getUTCFullYear();
// outMsg.data.year = outMsg.data.ts.getUTCFullYear();
outMsg.data.year = outMsg.data.ts.getFullYear();
const dataObjs = _getSpecialDaysOfYear(this, outMsg.data.year);

@@ -640,0 +696,0 @@

{
"name": "node-red-contrib-german-holidays",
"version": "1.0.1",
"version": "1.0.2-beta",
"description": "NodeRED nodes to get holidays or special days (not even german holidays)",

@@ -20,4 +20,2 @@ "keywords": [

"scripts": {
"test": "camo-purge; eslint \"./**/*.js\" \"./**/*.html\"",
"camo-purg": "camo-purge; eslint \"./**/*.js\" \"./**/*.html\"",
"lintfix": "eslint --fix \"./**/*.js\" \"./**/*.html\"",

@@ -60,3 +58,2 @@ "lint": "eslint \"./**/*.js\" \"./**/*.html\"",

"devDependencies": {
"camo-purge": "^1.0.2",
"eslint": "^7.1.0",

@@ -63,0 +60,0 @@ "eslint-plugin-html": "^6.0.2",

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