Socket
Socket
Sign inDemoInstall

node-red-contrib-sun-position

Package Overview
Dependencies
1
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0-alpha.4 to 0.2.0-alpha.5

launch.json

195

nodes/lib/dateTimeHelper.js

@@ -11,12 +11,3 @@ /********************************************

handleError,
isLeapYear,
days_of_a_year,
getFirstDayOfMonth,
getLastDayOfMonth,
getSpecialDayOfMonth,
getComparableDateFormat,
parseComparableDateFormat,
getComparableDateFormat2,
parseComparableDateFormat2,
getTimeDiff,
checkLimits,

@@ -26,3 +17,2 @@ addOffset,

normalizeDate,
normalizeDateUTC,
getTimeOfText,

@@ -32,6 +22,3 @@ getDateOfText,

getNodeId,
formatDate,
getFormattedDateOut,
parseDate,
parseDateTime,
parseDateFromFormat

@@ -71,20 +58,2 @@ };

/**
* get the number of days in a year
* @param {number} year year to get info
* @returns {number} number of days in given year
*/
function days_of_a_year(year) {
return isLeapYear(year) ? 366 : 365;
}
/**
* indicates if a year is a leap year
* @param {*} year year to check
* @returns {bool} *true* if the given year is a leap year
*/
function isLeapYear(year) {
return year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
}
/*******************************************************************************************************/
/**
* gives a ID of a node

@@ -95,3 +64,2 @@ * @param {any} node a node

function getNodeId(node) {
// node.debug(node.debug(util.inspect(srcNode, Object.getOwnPropertyNames(srcNode))));
return '[' + node.type + ((node.name) ? '/' + node.name + ':' : ':') + node.id + ']';

@@ -114,3 +82,3 @@ }

*/
function getComparableDateFormat(date) {
function _getComparableDateFormat(date) {
return Number(date.getFullYear() +

@@ -169,3 +137,3 @@ pad2(date.getMonth() + 1) +

*/
function getFirstDayOfMonth(year, month, dayOfWeek) {
function _getFirstDayOfMonth(year, month, dayOfWeek) {
const d = new Date(year, month, 1);

@@ -186,3 +154,3 @@ dayOfWeek = dayOfWeek || 1; // Monday

*/
function getLastDayOfMonth(year, month, dayOfWeek) {
function _getLastDayOfMonth(year, month, dayOfWeek) {
const d = new Date(year, month+1, 0);

@@ -206,29 +174,29 @@ dayOfWeek = dayOfWeek || 1; // Monday

case 'first Monday':
return getFirstDayOfMonth(year, month, 1);
return _getFirstDayOfMonth(year, month, 1);
case 'first Tuesday':
return getFirstDayOfMonth(year, month, 2);
return _getFirstDayOfMonth(year, month, 2);
case 'first Wednesday':
return getFirstDayOfMonth(year, month, 3);
return _getFirstDayOfMonth(year, month, 3);
case 'first Thursday':
return getFirstDayOfMonth(year, month, 4);
return _getFirstDayOfMonth(year, month, 4);
case 'first Friday':
return getFirstDayOfMonth(year, month, 5);
return _getFirstDayOfMonth(year, month, 5);
case 'first Saturday':
return getFirstDayOfMonth(year, month, 6);
return _getFirstDayOfMonth(year, month, 6);
case 'first Sunday':
return getFirstDayOfMonth(year, month, 0);
return _getFirstDayOfMonth(year, month, 0);
case 'last Monday':
return getLastDayOfMonth(year, month, 1);
return _getLastDayOfMonth(year, month, 1);
case 'last Tuesday':
return getLastDayOfMonth(year, month, 2);
return _getLastDayOfMonth(year, month, 2);
case 'last Wednesday':
return getLastDayOfMonth(year, month, 3);
return _getLastDayOfMonth(year, month, 3);
case 'last Thursday':
return getLastDayOfMonth(year, month, 4);
return _getLastDayOfMonth(year, month, 4);
case 'last Friday':
return getLastDayOfMonth(year, month, 5);
return _getLastDayOfMonth(year, month, 5);
case 'last Saturday':
return getLastDayOfMonth(year, month, 6);
return _getLastDayOfMonth(year, month, 6);
case 'last Sunday':
return getLastDayOfMonth(year, month, 0);
return _getLastDayOfMonth(year, month, 0);
}

@@ -245,3 +213,3 @@ return null;

*/
function parseComparableDateFormat(date) {
function _parseComparableDateFormat(date) {
date = String(date);

@@ -264,3 +232,3 @@ const year = date.substr(0, 4);

*/
function getComparableDateFormat2(date) {
function _getComparableDateFormat2(date) {
return Number(date.getFullYear() +

@@ -280,3 +248,3 @@ pad2(date.getMonth() + 1) +

*/
function parseComparableDateFormat2(date) {
function _parseComparableDateFormat2(date) {
date = String(date);

@@ -415,35 +383,2 @@ const year = date.substr(0, 4);

/**
* normalize date by adding offset, get only the next valid date, etc...
* @param {Date} d input Date to normalize
* @param {number} offset offset to add tot he Date object
* @param {number} multiplier multiplier for the offset
* @param {number} next If date is less then today this number of days will be added to the date
* @param {Array.<number>} days array of allowed days
* @return {Date} a normalized date moved tot the future to fulfill all conditions
*/
function normalizeDateUTC(d, offset, multiplier, next, days) {
console.debug('normalizeDateUTC d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days); // eslint-disable-line
d = addOffset(d, offset, multiplier);
if (next && !isNaN(next)) {
const now = new Date();
d.setUTCMilliseconds(0);
now.setUTCMilliseconds(600); // security
const cmp = now.getTime();
if (d.getTime() <= cmp) {
d.setUTCDate(d.getUTCDate() + Number(next));
}
}
if (days && (days !== '*') && (days !== '')) {
const dayx = calcDayOffset(days, d.getUTCDay());
if (dayx > 0) {
d.setUTCDate(d.getUTCDate() + dayx);
}
}
return d;
}
/*******************************************************************************************************/
/**
* parses a string which contains only a time to a Date object of today

@@ -477,3 +412,3 @@ * @param {string} t text representation of a time

function getDateOfText(dt, preferMonthFirst) {
console.log('getDateOfText dt=' + util.inspect(dt)); // eslint-disable-line
// console.log('getDateOfText dt=' + util.inspect(dt)); // eslint-disable-line
if (dt === null || typeof dt === 'undefined') {

@@ -529,5 +464,5 @@ throw new Error('Could not evaluate as a valid Date or time. Value is null or undefined!');

if (typeof dt === 'string') {
let res = parseDateTime(dt, preferMonthFirst);
let res = _parseDateTime(dt, preferMonthFirst);
if (res !== null) { return res; }
res = parseDate(dt, preferMonthFirst);
res = _parseDate(dt, preferMonthFirst);
if (res !== null) { return res; }

@@ -816,3 +751,3 @@ res = _parseArray(dt, dateFormat.parseTimes);

*/
function formatDate(date, mask, utc, dayNames, monthNames, dayDiffNames) {
function _formatDate(date, mask, utc, dayNames, monthNames, dayDiffNames) {
if (dayNames) {

@@ -834,24 +769,2 @@ dateFormat.i18n.dayNames = dayNames;

/**
* gives the difference between two times in Milliseconds
* @param {Date} time1 - JavaScript Date object
* @param {Date} [time2] - JavaScript Date object, if not defined, now will be used
* @param {Number} [limit] - limit in milliseconds. If defined and result is less then limit, result will be always a positive value.
* @return {Number} returns a number, string or object depending on the given Format
*/
function getTimeDiff(time1, time2, limit) {
if (!time2) {
time2 = new Date();
}
let millis = time1.getTime() - time2.getTime();
if (limit) {
while (millis < limit) {
millis += 86400000; // 24h
}
}
return millis;
}
/**
* pre defined formats of a given date

@@ -866,6 +779,6 @@ * @param {Date} date - JavaScript Date to format

function getFormattedDateOut(date, format, dayNames, monthNames, dayDiffNames) {
console.log('getFormattedDateOut date=' + date + ' --> format=' + format + ' [' + dayNames + '] - [' + monthNames + '] [' + dayDiffNames + ']'); // eslint-disable-line
console.debug('getFormattedDateOut date=' + date + ' --> format=' + format + ' [' + dayNames + '] - [' + monthNames + '] [' + dayDiffNames + ']'); // eslint-disable-line
format = format || 0;
if (isNaN(format)) {
return formatDate(date, String(format), false, dayNames, monthNames, dayDiffNames);
return _formatDate(date, String(format), false, dayNames, monthNames, dayDiffNames);
}

@@ -895,5 +808,5 @@

case 10: // timeformat_YYYYMMDDHHMMSS
return getComparableDateFormat(date);
return _getComparableDateFormat(date);
case 11: // timeformat_YYYYMMDD_HHMMSS
return getComparableDateFormat2(date);
return _getComparableDateFormat2(date);
case 12: // timeformat_localDate - 26.12.2018 - timeformat_d - 6/15/2009

@@ -908,13 +821,9 @@ return date.toLocaleDateString();

case 16: // timeformat_weekday - Montag, 22.12.
return formatDate(date, 'dddd, d.m.', false, dayNames, monthNames, dayDiffNames);
return _formatDate(date, 'dddd, d.m.', false, dayNames, monthNames, dayDiffNames);
case 17: // timeformat_weekday2 - heute 22.12., morgen 23.12., übermorgen 24.12., in 3 Tagen 25.12., Montag, 26.12.
return formatDate(date, 'xx, d.m.', false, dayNames, monthNames, dayDiffNames);
return _formatDate(date, 'xx, d.m.', false, dayNames, monthNames, dayDiffNames);
}
const now = new Date();
console.log('date='+util.inspect(date)); // eslint-disable-line
console.log('now='+util.inspect(now)); // eslint-disable-line
const delay = (date.getTime() - now.getTime());
console.log('delay='+util.inspect(delay)); // eslint-disable-line
return {

@@ -1239,4 +1148,3 @@ date,

}
console.log(`getDateFromFormat out year=${year} month=${month} date=${date} hh=${hh} mm=${mm} ss=${ss} ll=${ll}`); // eslint-disable-line
// console.log(`getDateFromFormat out year=${year} month=${month} date=${date} hh=${hh} mm=${mm} ss=${ss} ll=${ll}`); // eslint-disable-line
return new Date(year, month - 1, date, hh, mm, ss, ll);

@@ -1262,2 +1170,12 @@ }

/**
* check if a string is an integer
* @param {string} str string to check
* @returns boolean if it is a valid integer
*/
function _isTimestamp(str) {
const n = Math.floor(Number(str));
return n !== Infinity && String(n) === str && n > 946684800000;
}
/**
* This function takes a date string and tries to match it to a

@@ -1273,4 +1191,4 @@ * number of possible date formats to get the value. It will try to

*/
function parseDate(val, preferMonthFirst) {
console.debug('parseDate val=' + val + ' - preferMonthFirst=' + preferMonthFirst); // eslint-disable-line
function _parseDate(val, preferMonthFirst) {
console.debug('_parseDate val=' + val + ' - preferMonthFirst=' + preferMonthFirst); // eslint-disable-line
let res = _parseArray(val, (preferMonthFirst) ? dateFormat.parseDates.monthFirst : dateFormat.parseDates.dateFirst);

@@ -1290,4 +1208,4 @@ if (res !== null) { return res; }

*/
function parseDateTime(val, preferMonthFirst) {
console.debug('parseDateTime val=' + val + ' - preferMonthFirst=' + preferMonthFirst); // eslint-disable-line
function _parseDateTime(val, preferMonthFirst) {
console.debug('_parseDateTime val=' + val + ' - preferMonthFirst=' + preferMonthFirst); // eslint-disable-line
function mix(lst1, lst2, result) {

@@ -1346,17 +1264,21 @@ for (let i = 0; i < lst1.length; i++) {

console.debug('try parse ' + util.inspect(val) + ' preferMonthFirst=' + preferMonthFirst); // eslint-disable-line
let res = parseDateTime(val, preferMonthFirst);
let res = _parseDateTime(val, preferMonthFirst);
if (res !== null) { return res; }
res = parseDate(val, preferMonthFirst);
res = _parseDate(val, preferMonthFirst);
if (res !== null) { return res; }
res = _parseArray(val, dateFormat.parseTimes);
if (res !== null) { return res; }
console.debug(`try parse last try res=${res}`); // eslint-disable-line
res = Date.parse(val);
if (isNaN(res)) {
return null;
if (!isNaN(res)) {
return new Date(res);
}
return new Date(res);
if (!isNaN(val) && _isTimestamp(val)) {
const dto = new Date(val);
if (dto !== 'Invalid Date' && !isNaN(dto)) {
return dto;
}
}
return null;
};
switch (Number(format)) {

@@ -1376,6 +1298,6 @@ case 0: // UNIX Timestamp

case 4: // timeformat_YYYYMMDDHHMMSS
res = parseComparableDateFormat(date);
res = _parseComparableDateFormat(date);
break;
case 5: // timeformat_YYYYMMDD_HHMMSS
res = parseComparableDateFormat2(date);
res = _parseComparableDateFormat2(date);
break;

@@ -1388,2 +1310,3 @@ default: {

}
console.debug('result='+ util.inspect(res) + ' ' + isNaN(res)); // eslint-disable-line
if (res === 'Invalid Date' || isNaN(res) || res === null) {

@@ -1390,0 +1313,0 @@ throw new Error('could not evaluate format of ' + date + ' (' + format+')');

@@ -263,3 +263,2 @@ /*

}
// console.log(util.inspect(result));

@@ -266,0 +265,0 @@ return result;

@@ -89,20 +89,2 @@ /********************************************

const node = this;
/*
console.log(hlp.getNodeId(node) +' old lon '+n.longitude);
console.log(hlp.getNodeId(node) +' old lat '+n.latitude);
console.log(hlp.getNodeId(node) +' new lon '+this.credentials.posLongitude);
console.log(hlp.getNodeId(node) +' new lat '+this.credentials.posLatitude);
console.log(hlp.getNodeId(node) +' result lon '+node.longitude);
console.log(hlp.getNodeId(node) +' result lat '+node.latitude);
*/
/*
this.getSunTimes = () => {
//node.debug('getSunTimes');
let res = sunTimesCheck(node);
res.today = node.sunTimesToday;
res.tomorrow = node.sunTimesTomorrow;
return res;
}
*/
this.getSunTime = (now, value, offset, multiplier, next, days) => {

@@ -142,10 +124,2 @@ node.debug('getSunTime value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);

this.getMoonTimes = () => {
// node.debug('getMoonTimes');
const res = moonTimesCheck(node);
res.today = node.moonTimesToday;
res.tomorrow = node.moonTimesTomorow;
return res;
};
this.getMoonTime = (now, value, offset, multiplier, next, days) => {

@@ -189,3 +163,10 @@ node.debug('getMoonTime value=' + value + ' offset=' + offset + ' next=' + next + ' days=' + days);

// 'msg', 'flow', 'global', 'num', 'bin', 'env', 'jsonata'
if (type === '' || type === 'none' || typeof type === 'undefined' || type === null) {
if (type === 'num') {
data = value;
} else if (type === '' || typeof type === 'undefined' || type === null) {
if (isNaN(value)) {
return 0;
}
data = value;
} else if (type === 'none') {
return 0;

@@ -213,8 +194,9 @@ } else if (type === 'msgPayload') {

this.getOutDataProp = (_srcNode, msg, vType, value, format, offset, multiplier, days) => {
_srcNode.debug('getOutDataProp type='+vType+' value='+value+' format='+format+' offset='+offset+' multiplier='+multiplier);
this.getOutDataProp = (_srcNode, msg, vType, value, format, offset, offsetType, multiplier, days) => {
_srcNode.debug('getOutDataProp type='+vType+' value='+value+' format='+format+' offset='+offset+' offset='+offsetType+' multiplier='+multiplier);
let result = null;
if (vType === null || vType === 'none' || vType === '' || (typeof vType === 'undefined')) {
if (value === '' || (typeof value === 'undefined')) {
result = hlp.addOffset(Date.now(), offset, multiplier);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = hlp.addOffset((new Date()), offsetX, multiplier);
return node.formatOutDate(result, format);

@@ -224,3 +206,6 @@ }

} else if (vType === 'date') {
result = hlp.addOffset(Date.now(), offset, multiplier);
return Date.now();
} else if (vType === 'dateSpecific') {
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = hlp.addOffset((new Date()), offsetX, multiplier);
return node.formatOutDate(result, format);

@@ -239,5 +224,7 @@ } else if (vType === 'msgPayload') {

if (vType === 'pdsTime') { // sun
result = node.getSunTime(Date.now(), value, offset, multiplier, undefined, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = node.getSunTime((new Date()), value, offsetX, multiplier, undefined, days);
} else if (vType === 'pdmTime') { // moon
result = node.getMoonTime(Date.now(), value, offset, multiplier, undefined, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = node.getMoonTime((new Date()), value, offsetX, multiplier, undefined, days);
}

@@ -250,3 +237,4 @@ if (result && result.value && !result.error) {

result = hlp.getDateOfText(String(value));
result = hlp.normalizeDate(Date.now(), offset, multiplier, undefined, days); // hlp.addOffset(result, offset, multiplier);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = hlp.normalizeDate((new Date()), offsetX, multiplier, undefined, days);
return node.formatOutDate(result, format);

@@ -257,3 +245,4 @@ } else if (vType === 'dayOfMonth') {

if (result !== null && typeof result !== 'undefined') {
result = hlp.addOffset(result, offset, multiplier);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = hlp.addOffset(result, offsetX, multiplier);
return node.formatOutDate(result, format);

@@ -266,22 +255,27 @@ }

this.getDateFromProp = (_srcNode, msg, vType, value, format, offset, multiplier) => {
_srcNode.debug('getDateFromProp type='+vType+' value='+value+' format='+format+' offset='+offset+' multiplier='+multiplier);
this.getDateFromProp = (_srcNode, msg, vType, value, format, offset, offsetType, multiplier) => {
_srcNode.debug('getDateFromProp type='+vType+' value='+value+' format='+format+' offset='+offset+ ' offsetType=' + offsetType +' multiplier='+multiplier);
let result = null;
try {
if (vType === null || vType === 'none' || vType === '') {
return Date.now();
return (new Date());
} else if (vType === 'date') {
return hlp.addOffset(Date.now(), offset, multiplier);
return new Date();
} else if (vType === 'dateSpecific') {
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
return hlp.addOffset((new Date()), offsetX, multiplier);
} else if (vType === 'dayOfMonth') {
let d = new Date();
d = hlp.getSpecialDayOfMonth(d.getFullYear(),d.getMonth(), value);
return hlp.addOffset(d, offset, multiplier);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
return hlp.addOffset(d, offsetX, multiplier);
} else if ((vType === 'pdsTime') || (vType === 'pdmTime')) {
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
if (vType === 'pdsTime') {
// sun
result = node.getSunTime(Date.now(), value, offset, multiplier);
result = node.getSunTime((new Date()), value, offsetX, multiplier);
result.fix = true;
} else if (vType === 'pdmTime') {
// moon
result = node.getMoonTime(Date.now(), value, offset, multiplier);
result = node.getMoonTime((new Date()), value, offsetX, multiplier);
result.fix = true;

@@ -295,3 +289,4 @@ }

result = hlp.getDateOfText(String(value));
return hlp.addOffset(result, offset, multiplier);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
return hlp.addOffset(result, offsetX, multiplier);
} else if (vType === 'msgPayload') {

@@ -308,4 +303,5 @@ result = msg.payload;

if (result !== null && typeof result !== 'undefined') {
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = hlp.parseDateFromFormat(result, format, RED._('position-config.days'), RED._('position-config.month'), RED._('position-config.dayDiffNames'));
return hlp.addOffset(result, offset, multiplier);
return hlp.addOffset(result, offsetX, multiplier);
}

@@ -321,5 +317,4 @@ } catch (err) {

this.getTimeProp = (_srcNode, msg, vType, value, offset, multiplier, next, days) => {
node.debug('getTimeProp ' + hlp.getNodeId(_srcNode) + ' vType=' + vType + ' value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
const now = new Date();
this.getTimeProp = (_srcNode, msg, vType, value, offset, offsetType, multiplier, next, days) => {
node.debug('getTimeProp ' + hlp.getNodeId(_srcNode) + ' vType=' + vType + ' value=' + value + ' offset=' + offset + ' offsetType=' + offsetType + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
let result = {

@@ -331,11 +326,18 @@ value: null,

try {
if (vType === '' || vType === 'none' || days === '') {
// nix
if (days === '') {
result.error = 'No valid Days given!';
} else if (vType === '' || vType === 'none' || days === '') {
result.error = 'wrong type "' + vType + '"="' + value+'"';
} else if (vType === 'date') {
result.value = hlp.normalizeDate(now, offset, multiplier, next, days);
result.value = (new Date());
result.fix = true;
} else if (vType === 'dateSpecific') {
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result.value = hlp.normalizeDate((new Date()), offsetX, multiplier, next, days);
result.fix = true;
} else if (vType === 'entered') {
result.value = hlp.getTimeOfText(String(value), now);
result.value = hlp.getTimeOfText(String(value), (new Date()));
if (result.value !== null) {
result.value = hlp.normalizeDate(result.value, offset, multiplier, next, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result.value = hlp.normalizeDate(result.value, offsetX, multiplier, next, days);
}

@@ -345,7 +347,9 @@ result.fix = true;

// sun
result = node.getSunTime(now, value, offset, multiplier, next, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = node.getSunTime((new Date()), value, offsetX, multiplier, next, days);
result.fix = true;
} else if (vType === 'pdmTime') {
// moon
result = node.getMoonTime(now, value, offset, multiplier, next, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result = node.getMoonTime((new Date()), value, offsetX, multiplier, next, days);
result.fix = true;

@@ -358,3 +362,4 @@ } else {

result.value = hlp.getDateOfText(res);
result.value = hlp.normalizeDate(result.value, offset, multiplier, next, days);
const offsetX = node.getFloatProp(node, msg, offsetType, offset);
result.value = hlp.normalizeDate(result.value, offsetX, multiplier, next, days);
// node.debug(String(res) + ' -- ' + result.value);

@@ -377,4 +382,3 @@ } else {

}
result.value = now;
result.value = (new Date());
}

@@ -381,0 +385,0 @@

@@ -127,2 +127,8 @@ /************************************************************************/

},
DateSpecific: {
value: 'dateSpecific',
label: 'timestamp enhanced',
// icon: "icons/node-red-contrib-sun-position/inputTypeNone.png",
hasValue: false
},
MsgPayload: {

@@ -458,3 +464,3 @@ value: 'msgPayload',

function initDaysCheckbox(element, val) { // eslint-disable-line no-unused-vars
if (val === '*' || typeof val === 'undefined') {
if (val === '*' || typeof val === 'undefined' || val === null || val === '') {
$(element + ' input[type=checkbox]').prop('checked', true);

@@ -461,0 +467,0 @@ } else {

@@ -37,4 +37,3 @@ /********************************************

try {
const offset1 = node.positionConfig.getFloatProp(node,msg,config.inputOffsetType, config.inputOffset);
const inputData = node.positionConfig.getDateFromProp(node, msg, config.inputType, config.input, config.inputFormat, offset1, config.inputOffsetMultiplier);
const inputData = node.positionConfig.getDateFromProp(node, msg, config.inputType, config.input, config.inputFormat, config.inputOffset, config.inputOffsetType, config.inputOffsetMultiplier);
node.debug('inputData ' + util.inspect(inputData)); // eslint-disable-line

@@ -47,3 +46,3 @@

} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1Multiplier);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier);
}

@@ -84,3 +83,3 @@

if (operatorValid) {
const ruleoperand = node.positionConfig.getDateFromProp(node, msg, rule.operandType, rule.operandValue, rule.format, rule.offsetValue, rule.multiplier);
const ruleoperand = node.positionConfig.getDateFromProp(node, msg, rule.operandType, rule.operandValue, rule.format, rule.offsetValue, 'num', rule.multiplier);
node.debug('operand ' + util.inspect(ruleoperand));

@@ -87,0 +86,0 @@ node.debug('operator ' + util.inspect(rule.operator));

@@ -28,4 +28,3 @@ /********************************************

if (type !== 'none' && name) {
const offsetX = this.positionConfig.getFloatProp(node,offsetType, offset);
const res = node.positionConfig.getOutDataProp(node, msg, valueType, value, format, offsetX, multiplier, days);
const res = node.positionConfig.getOutDataProp(node, msg, valueType, value, format, offset, offsetType, multiplier, days);
if (res === null || (typeof res === 'undefined')) {

@@ -116,6 +115,3 @@ throw new Error('could not evaluate ' + valueType + '.' + value);

if (node.timeType !== 'none' && node.positionConfig) {
// (srcNode, msg, vType, value, offset, next, days)
// node.nextTime = hlp.getTimeProp(node, node.timeType, node.time, node.offset, node.offsetMultiplier, 1);
const nextTimeOffset = node.positionConfig.getFloatProp(node, undefined, node.offsetType, node.offset);
node.nextTimeData = node.positionConfig.getTimeProp(node, undefined, node.timeType, node.time, nextTimeOffset, node.offsetMultiplier, 1, node.timeDays);
node.nextTimeData = node.positionConfig.getTimeProp(node, undefined, node.timeType, node.time, node.offset, node.offsetType, node.offsetMultiplier, 1, node.timeDays);
if (node.nextTimeData.error) {

@@ -140,4 +136,4 @@ errorStatus = 'could not evaluate time';

node.positionConfig) {
const nextTimeOffset = node.positionConfig.getFloatProp(node, undefined, node.timeAltOffsetType, node.timeAltOffset);
node.nextTimeAltData = node.positionConfig.getTimeProp(node, undefined, node.timeAltType, node.timeAlt, nextTimeOffset, node.timeAltOffsetMultiplier, 1, node.timeAltDays);
// (_srcNode, msg, vType, value, offset, offsetType, multiplier, next, days)
node.nextTimeAltData = node.positionConfig.getTimeProp(node, undefined, node.timeAltType, node.timeAlt, node.timeAltOffset, node.timeAltOffsetType, node.timeAltOffsetMultiplier, 1, node.timeAltDays);
if (node.nextTimeAltData.error) {

@@ -283,3 +279,3 @@ errorStatus = 'could not evaluate alternate time';

try {
node.debug('input ' + util.inspect(msg));
node.debug('input ');
doCreateTimeout(node);

@@ -290,5 +286,3 @@ msg.topic = config.topic;

}
const offsetX = this.positionConfig.getFloatProp(node, node.payloadOffset, config.payloadOffsetType);
const value = node.positionConfig.getOutDataProp(node, msg, config.payloadType, config.payload, config.payloadTimeFormat, offsetX, config.payloadOffsetMultiplier);
const value = node.positionConfig.getOutDataProp(node, msg, config.payloadType, config.payload, config.payloadTimeFormat, node.payloadOffset, config.payloadOffsetType, config.payloadOffsetMultiplier);
if (value === null || (typeof value === 'undefined')) {

@@ -322,4 +316,4 @@ throw new Error('could not evaluate ' + config.payloadType + '.' + config.payload);

node.status({});
if (config.once) {
try {
try {
if (config.once) {
node.status({

@@ -337,15 +331,4 @@ fill: 'yellow',

}, (config.onceDelay || 0.1) * 1000);
} catch (err) {
node.error(err.message);
node.debug(util.inspect(err, Object.getOwnPropertyNames(err)));
node.status({
fill: 'red',
shape: 'ring',
text: RED._('time-inject.errors.error-title')
});
return;
}
return;
}
try {
doCreateTimeout(node, true);

@@ -352,0 +335,0 @@ } catch (err) {

@@ -250,4 +250,3 @@ /********************************************

try {
const offset1 = node.positionConfig.getFloatProp(node,msg,config.operand1OffsetType, config.operand1Offset);
const operand1 = node.positionConfig.getDateFromProp(node, msg, config.operand1Type, config.operand1, config.operand1Format, offset1, config.operand1OffsetMultiplier);
const operand1 = node.positionConfig.getDateFromProp(node, msg, config.operand1Type, config.operand1, config.operand1Format, config.operand1Offset, config.operand1OffsetType, config.operand1OffsetMultiplier);
node.debug('operand1 ' + util.inspect(operand1)); // eslint-disable-line

@@ -257,4 +256,3 @@ if (operand1 === null) {

}
const offset2 = node.positionConfig.getFloatProp(node,msg,config.operand2OffsetType, config.operand2Offset);
const operand2 = node.positionConfig.getDateFromProp(node, msg, config.operand2Type, config.operand2, config.operand2Format, offset2, config.operand2OffsetMultiplier);
const operand2 = node.positionConfig.getDateFromProp(node, msg, config.operand2Type, config.operand2, config.operand2Format, config.operand2Offset, config.operand2OffsetType, config.operand2OffsetMultiplier);
node.debug('operand2 ' + util.inspect(operand2)); // eslint-disable-line

@@ -279,4 +277,3 @@ if (operand2 === null) {

} else {
const resOffset = node.positionConfig.getFloatProp(node,msg,config.result1OffsetType, config.result1Offset);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, resOffset, config.result1Multiplier);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier);
}

@@ -283,0 +280,0 @@ // to

@@ -106,7 +106,7 @@ /********************************************

// node.debug('using alternate start time ' + result.altStartTime + ' - ' + config.startTimeAltType);
result.start = node.positionConfig.getTimeProp(node, msg, config.startTimeAltType, config.startTimeAlt, config.startOffsetAlt, config.startOffsetAltMultiplier);
result.start = node.positionConfig.getTimeProp(node, msg, config.startTimeAltType, config.startTimeAlt, config.startOffsetAlt, 'num', config.startOffsetAltMultiplier);
result.startSuffix = '⎇ ';
} else {
// node.debug('using standard start time ' + result.altStartTime + ' - ' + config.startTimeAltType);
result.start = node.positionConfig.getTimeProp(node, msg, config.startTimeType, config.startTime, config.startOffset, config.startOffsetMultiplier);
result.start = node.positionConfig.getTimeProp(node, msg, config.startTimeType, config.startTime, config.startOffset, 'num', config.startOffsetMultiplier);
}

@@ -116,7 +116,7 @@

// node.debug('using alternate end time ' + result.altEndTime + ' - ' + config.startTimeAltType);
result.end = node.positionConfig.getTimeProp(node, msg, config.endTimeAltType, config.endTimeAlt, config.endOffsetAlt, config.endOffsetAltMultiplier);
result.end = node.positionConfig.getTimeProp(node, msg, config.endTimeAltType, config.endTimeAlt, config.endOffsetAlt, 'num', config.endOffsetAltMultiplier);
result.endSuffix = ' ⎇';
} else {
// node.debug('using standard end time ' + result.altEndTime + ' - ' + config.startTimeAltType);
result.end = node.positionConfig.getTimeProp(node, msg, config.endTimeType, config.endTime, config.endOffset, config.endOffsetMultiplier);
result.end = node.positionConfig.getTimeProp(node, msg, config.endTimeType, config.endTime, config.endOffset, 'num', config.endOffsetMultiplier);
}

@@ -123,0 +123,0 @@

{
"name": "node-red-contrib-sun-position",
"version": "0.2.0-alpha.4",
"version": "0.2.0-alpha.5",
"description": "NodeRED nodes to get sun and moon position",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc