node-red-contrib-sun-position
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -12,2 +12,3 @@ /******************************************** | ||
calcTimeValue, | ||
calcTimeValueUTC, | ||
getTimeOfText, | ||
@@ -108,2 +109,39 @@ getTimeOfTextUTC, | ||
let now = new Date(); | ||
d.setMilliseconds(0); | ||
now.setMilliseconds(600); //security | ||
let cmp = now.getTime(); | ||
if (d.getTime() <= cmp) { | ||
d = d.addDays(Number(next)); | ||
} | ||
} | ||
if (days && (days !== '*') && (days !== '')) { | ||
let daystart = d.getDay(); | ||
let dayx = 0; | ||
let daypos = daystart; | ||
while (days.indexOf(daypos) === -1) { | ||
dayx += 1; | ||
if ((daystart + dayx) > 6) { | ||
daypos = (daystart * -1) + dayx - 1; | ||
} else { | ||
daypos = daystart + dayx; | ||
} | ||
if (dayx > 6) { | ||
dayx = -1; | ||
break; | ||
} | ||
} | ||
if (dayx > 0) { | ||
d = d.addDays(dayx); | ||
} | ||
} | ||
return d; | ||
} | ||
/*******************************************************************************************************/ | ||
function calcTimeValueUTC(d, offset, next, days) { | ||
//console.debug('calcTimeValueUTC d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days); | ||
if (offset && !isNaN(offset) && offset !== 0) { | ||
d = new Date(d.getTime() + offset * 1000); //- does not work | ||
} | ||
if (next && !isNaN(next)) { | ||
let now = new Date(); | ||
d.setUTCMilliseconds(0); | ||
@@ -186,3 +224,3 @@ now.setUTCMilliseconds(600); //security | ||
} | ||
return calcTimeValue(d, offset, next, days) | ||
return calcTimeValueUTC(d, offset, next, days) | ||
} | ||
@@ -198,3 +236,3 @@ return null; | ||
if (dto !== "Invalid Date" && !isNaN(dto)) { | ||
return calcTimeValue(dto, offset, next, days); | ||
return calcTimeValueUTC(dto, offset, next, days); | ||
} else { | ||
@@ -201,0 +239,0 @@ let result = getTimeOfTextUTC(String(date), tzOffset, offset, next, days); |
{ | ||
"name": "node-red-contrib-sun-position", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "NodeRED nodes to get sun and moon position", | ||
@@ -5,0 +5,0 @@ "main": "none", |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
574228
2381