Socket
Socket
Sign inDemoInstall

node-red-contrib-sun-position

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-sun-position - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

58

nodes/lib/sunPosHelper.js

@@ -13,3 +13,5 @@ /********************************************

getTimeOfText,
getTimeOfTextUTC,
getDateOfText,
getDateOfTextUTC,
getTimeNumber,

@@ -20,3 +22,3 @@ getNodeId

/*******************************************************************************************************/
Date.prototype.addDays = function (days) {
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());

@@ -108,3 +110,3 @@ date.setUTCDate(date.getUTCDate() + days);

d.setUTCMilliseconds(0);
now.setUTCMilliseconds(600);//security
now.setUTCMilliseconds(600); //security
let cmp = now.getTime();

@@ -138,12 +140,12 @@ if (d.getTime() <= cmp) {

/*******************************************************************************************************/
function getTimeOfText(t, tzOffset, offset, next, days) {
//console.debug('getTimeOfText t=' + t + ' tzOffset=' + tzOffset + ' offset=' + offset + ' next=' + next + ' days=' + days);
let d = new Date();
function getTimeOfText(t, offset, next, days, date) {
//console.debug('getTimeOfText t=' + t + ' offset=' + offset + ' next=' + next + ' days=' + days);
let d = date || new Date();
if (t && (t.indexOf('.') === -1) && (t.indexOf('-') === -1)) {
let matches = t.match(/(0[0-9]|1[0-9]|2[0-3]|[0-9])(?::([0-5][0-9]|[0-9]))(?::([0-5][0-9]|[0-9]))?\s*(p?)/);
if (matches) {
d.setUTCHours(parseInt(matches[1]) + (matches[4] ? 12 : 0));
d.setUTCMinutes((parseInt(matches[2]) || 0) + tzOffset);
d.setUTCSeconds(parseInt(matches[3]) || 0);
d.setUTCMilliseconds(0);
d.setHours((parseInt(matches[1]) + (matches[4] ? 12 : 0)),
(parseInt(matches[2]) || 0),
(parseInt(matches[3]) || 0), 0);
console.log(d);
} else {

@@ -157,3 +159,3 @@ return null;

/*******************************************************************************************************/
function getDateOfText(date, tzOffset, offset, next, days) {
function getDateOfText(date, offset, next, days) {
if (!isNaN(date)) {

@@ -166,3 +168,3 @@ date = Number(date);

} else {
let result = getTimeOfText(String(date), tzOffset, offset, next, days);
let result = getTimeOfText(String(date), offset, next, days);
if (result != null) {

@@ -173,2 +175,36 @@ return result;

throw new Error("could not evaluate " + String(date) + ' as a valid Date or time.');
};
/*******************************************************************************************************/
function getTimeOfTextUTC(t, tzOffset, offset, next, days, date) {
console.debug('getTimeOfTextUTC t=' + t + ' tzOffset=' + tzOffset + ' offset=' + offset + ' next=' + next + ' days=' + days);
let d = date || new Date();
if (t && (t.indexOf('.') === -1) && (t.indexOf('-') === -1)) {
let matches = t.match(/(0[0-9]|1[0-9]|2[0-3]|[0-9])(?::([0-5][0-9]|[0-9]))(?::([0-5][0-9]|[0-9]))?\s*(p?)/);
if (matches) {
d.setHours((parseInt(matches[1]) + (matches[4] ? 12 : 0)),
(parseInt(matches[2]) || 0) + (tzOffset || 0),
(parseInt(matches[3]) || 0), 0);
console.log(d);
} else {
return null;
}
return calcTimeValue(d, offset, next, days)
}
return null;
};
/*******************************************************************************************************/
function getDateOfTextUTC(date, tzOffset, offset, next, days) {
if (!isNaN(date)) {
date = Number(date);
}
let dto = new Date(date);
if (dto !== "Invalid Date" && !isNaN(dto)) {
return calcTimeValue(dto, offset, next, days);
} else {
let result = getTimeOfTextUTC(String(date), tzOffset, offset, next, days);
if (result != null) {
return result;
}
}
throw new Error("could not evaluate " + String(date) + ' as a valid Date or time.');
};

7

nodes/moon-position.js

@@ -8,3 +8,3 @@ /********************************************

module.exports = function (RED) {
module.exports = function(RED) {
"use strict";

@@ -21,3 +21,3 @@

this.on('input', function (msg) {
this.on('input', function(msg) {
try {

@@ -41,3 +41,3 @@ var ports = new Array(this.rules.length);

let chk = hlp.compareAzimuth(ports[0].payload.azimuth, low, high);
let chg = (node.azimuthPos[i] !== chk);
let chg = (node.azimuthPos[i] !== chk);
ports[0].payload.pos.push(chk);

@@ -64,2 +64,3 @@ ports[0].payload.posChanged = ports[0].payload.posChanged && chg;

});
function getNumProp(node, msg, vType, value) {

@@ -66,0 +67,0 @@ //node.debug('getNumProp vType=' + vType + ' value=' + value);

@@ -61,3 +61,3 @@ /********************************************

Date.prototype.addDays = function (days) {
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());

@@ -86,3 +86,3 @@ date.setUTCDate(date.getUTCDate() + days);

module.exports = function (RED) {
module.exports = function(RED) {
"use strict";

@@ -198,3 +198,4 @@

} else if (vType === 'entered') {
result.value = hlp.getTimeOfText(String(value), node.tzOffset, offset, next, days);
result.value = hlp.getTimeOfText(String(value), offset, next, days, now);
node.debug(String(value) + ' -- ' + result.value);
result.fix = true;

@@ -212,3 +213,4 @@ } else if (vType === 'pdsTime') {

let date = (val.now) ? val.now : ((val.date) ? val.date : ((val.time) ? val.time : ((val.ts) ? val.ts : "")));
result.value = hlp.getDateOfText(date, node.tzOffset, offset, next, days);
result.value = hlp.hlp.getDateOfText(date, offset, next, days);
node.debug(date + ' -- ' + result.value);
result.fix = true;

@@ -219,4 +221,5 @@ } else {

if (res) {
result.value = hlp.getDateOfText("" + res, node.tzOffset, offset, next, days);
result.value = hlp.getDateOfText(String(res), offset, next, days);
result.fix = false; // not a fixed time, because can be changed
node.debug(String(res) + ' -- ' + result.value);
} else {

@@ -223,0 +226,0 @@ result.error = "could not evaluate " + vType + '.' + value;

@@ -104,3 +104,3 @@ /********************************************

let millis = node.getScheduleTime(node.nextTime);
if (millis > 1000) {
if (millis > 500) {
node.debug('timeout ' + node.nextTime + ' is in ' + millis + 'ms');

@@ -147,2 +147,4 @@ let isAlt = (node.nextTimeAlt);

} else {
errorStatus = "invalid calculated time";
node.nextTime = null;
fixTimeStamp = false;

@@ -149,0 +151,0 @@ }

{
"name": "node-red-contrib-sun-position",
"version": "0.0.7",
"description": "NodeRED nodes to get sun and moon position",
"main": "none",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"predev": "npm i -g",
"dev": "node-red -v"
},
"author": {
"name": "Hypnos3",
"email": "hypnos3@online.de",
"url": "https://github.com/hypnos3"
},
"contributors": [{
"name": "Hypnos3",
"url": "https://github.com/hypnos3"
}],
"keywords": [
"node-red",
"sun-position",
"moon-position",
"heavenly body",
"sun",
"sun events",
"moon",
"moon events",
"position",
"luminary",
"suncalc",
"mooncalc",
"node-red",
"router",
"switch",
"inject",
"time"
],
"homepage": "https://github.com/Hypnos3/node-red-contrib-sun-position",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/Hypnos3/node-red-contrib-sun-position"
},
"bugs": {
"url": "https://github.com/Hypnos3/node-red-contrib-sun-position/issues"
},
"dependencies": {
"suncalc": "^1.8.0"
},
"node-red": {
"nodes": {
"position-config": "nodes/position-config.js",
"sun-position": "nodes/sun-position.js",
"moon-position": "nodes/moon-position.js",
"within-time-switch": "nodes/within-time-switch.js",
"time-inject": "nodes/time-inject.js"
}
},
"extensions": [
"js",
"html"
]
"name": "node-red-contrib-sun-position",
"version": "0.0.8",
"description": "NodeRED nodes to get sun and moon position",
"main": "none",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"predev": "npm i -g",
"dev": "node-red -v"
},
"author": {
"name": "Hypnos3",
"email": "hypnos3@online.de",
"url": "https://github.com/hypnos3"
},
"contributors": [{
"name": "Hypnos3",
"url": "https://github.com/hypnos3"
}],
"keywords": [
"node-red",
"sun-position",
"moon-position",
"heavenly body",
"sun",
"sun events",
"moon",
"moon events",
"position",
"luminary",
"suncalc",
"mooncalc",
"node-red",
"router",
"switch",
"inject",
"time"
],
"homepage": "https://github.com/Hypnos3/node-red-contrib-sun-position",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/Hypnos3/node-red-contrib-sun-position"
},
"bugs": {
"url": "https://github.com/Hypnos3/node-red-contrib-sun-position/issues"
},
"dependencies": {
"suncalc": "^1.8.0"
},
"node-red": {
"nodes": {
"position-config": "nodes/position-config.js",
"sun-position": "nodes/sun-position.js",
"moon-position": "nodes/moon-position.js",
"within-time-switch": "nodes/within-time-switch.js",
"time-inject": "nodes/time-inject.js"
}
},
"extensions": [
"js",
"html"
]
}

Sorry, the diff of this file is not supported yet

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