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.3.1 to 0.3.2

113

nodes/lib/dateTimeHelper.js

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

pad2,
customISOstring,
pad,
clipStrLength,

@@ -34,2 +34,3 @@ countDecimals,

getFormattedDateOut,
getDateFromFormat,
parseDateFromFormat,

@@ -104,21 +105,18 @@ topicReplace

}
/*******************************************************************************************************/
/**
* Formats a Date object to a custom ISO String
* @param {*} date Date to Format
* @param {*} offset Offset for Format
* creates a string from a number with leading zeros
* @param {string|number|boolean} n number to format
* @param {number} [len] length of number (default 2)
* @returns {string} number with minimum digits as defined in length
*/
function customISOstring(date, offset) {
date = new Date(date); // copy instance
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));
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) {
val = '0' + val;
}
return val;
}
/*******************************************************************************************************/

@@ -675,3 +673,2 @@ /* Node-Red Helper functions */

* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*

@@ -691,18 +688,7 @@ * http://blog.stevenlevithan.com/archives/date-time-format

const dateFormat = (function () {
const token = /x{1,2}|d{1,4}|E{1,2}|M{1,4}|NNN|yy(?:yy)?|([HhKkmsTt])\1?|l{1,3}|[LoSZ]|"[^"]*"|'[^']*'/g;
const token = /x{1,2}|d{1,4}|E{1,2}|M{1,4}|NNN|yy(?:yy)?|([HhKkmsTt])\1?|l{1,3}|[LSZ]|z{1,2}|o{1,4}|"[^"]*"|'[^']*'/g;
const timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
// const timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g;
// const timezoneClip = /[^-+\dA-Z]/g;
const timezoneClip = /[^-+\dA-Z]/g;
const pad = function (val, len) {
val = String(val);
len = len || 2;
while (val.length < len) {
val = '0' + val;
}
return val;
};
// Regexes and supporting functions are cached through closure

@@ -725,3 +711,3 @@ return function (date, mask, utc) {

mask = String(dF.masks[mask] || mask || dF.masks.default);
mask = String(mask || dateFormat.isoDateTime);

@@ -747,3 +733,3 @@ // Allow setting the utc argument via the mask

d,
dd: pad(d),
dd: pad2(d),
ddd: dF.i18n.dayNames[D + 7],

@@ -754,3 +740,3 @@ dddd: dF.i18n.dayNames[D],

M: M + 1,
MM: pad(M + 1),
MM: pad2(M + 1),
MMM: dF.i18n.monthNames[M + 12],

@@ -762,18 +748,18 @@ MMMM: dF.i18n.monthNames[M],

h: H % 12 || 12,
hh: pad(H % 12 || 12),
hh: pad2(H % 12 || 12),
H, // 0-23
HH: pad(H), // 00-23
HH: pad2(H), // 00-23
k: (H % 12 || 12) - 1,
kk: pad((H % 12 || 12) - 1),
kk: pad2((H % 12 || 12) - 1),
K: H + 1,
KK: pad(H + 1),
KK: pad2(H + 1),
m,
mm: pad(m),
mm: pad2(m),
s,
ss: pad(s),
ss: pad2(s),
l,
ll: pad(l),
ll: pad2(l),
lll: pad(l, 3),
L: Math.round(l / 100),
LL: pad(Math.round(l / 10)),
LL: pad2(Math.round(l / 10)),
LLL: pad(l, 3),

@@ -784,4 +770,9 @@ t: H < 12 ? 'a' : 'p',

TT: H < 12 ? 'AM' : 'PM',
Z: utc ? 'UTC' : (String(date).match(timezone) || ['']).pop().replace(timezoneClip, ''),
o: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
Z: utc ? 'UTC' : /.*\s(.+)/.exec(date.toLocaleTimeString([], { timeZoneName: 'short' }))[1],
z: utc ? '' : (String(date).match(/\b(?:GMT|UTC)(?:[-+]\d{4})?\b/g) || ['']).pop(),
zz: utc ? '' : (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
o: (o > 0 ? '-' : '+') + pad2(Math.floor(Math.abs(o) / 60)) + ':' + pad2(Math.abs(o) % 60),
oo: (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
ooo: utc ? 'Z' : (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
oooo: utc ? 'UTC' : (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ['th', 'st', 'nd', 'rd'][d % 10 > 3 ? 0 : (d % 100 - d % 10 !== 10) * d % 10],

@@ -799,17 +790,3 @@ x: dayDiff,

// Some common format strings
dateFormat.masks = {
default: 'ddd MMM dd yyyy HH:mm:ss',
shortDate: 'm/d/yy',
mediumDate: 'MMM d, yyyy',
longDate: 'MMMM d, yyyy',
fullDate: 'dddd, MMMM d, yyyy',
shortTime: 'h:mm TT',
mediumTime: 'h:mm:ss TT',
longTime: 'h:mm:ss TT Z',
isoDate: 'yyyy-MM-dd',
isoTime: 'HH:MM:ss',
isoDateTime: 'yyyy-MM-dd\'T\'HH:mm:ss',
isoUtcDateTime: 'UTC:yyyy-MM-dd\'T\'HH:mm:ss\'Z\''
};
dateFormat.isoDateTime = 'yyyy-MM-dd\'T\'HH:mm:ss';
dateFormat.parseDates = {

@@ -968,2 +945,16 @@ monthFirst : ['MMM d, y', 'MMM d,y', 'M/d/y', 'M-d-y', 'M.d.y', 'MMM-d', 'M/d', 'MMM d', 'M-d'],

return dateFormat(date, 'xx, d.M.', utc);
case 18: { // customISOstring(date, offset)
date = new Date(date); // 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));
}
}

@@ -1363,3 +1354,3 @@

let checkList = [dateFormat.masks.isoDateTime];
let checkList = [dateFormat.isoDateTime];
if (preferMonthFirst) {

@@ -1366,0 +1357,0 @@ checkList = mix(dateFormat.parseDates.monthFirst, dateFormat.parseTimes, checkList);

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

'use strict';
// sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas

@@ -22,19 +23,32 @@ // shortcuts for easier to read formulas

const rad = PI / 180;
// sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas
// date/time constants and conversions
const dayMs = 1000 * 60 * 60 * 24;
const J1970 = 2440588;
const dayMs = 86400000; // 1000 * 60 * 60 * 24;
const J1970 = 2440587.5;
const J2000 = 2451545;
function toJulian(date) {
return date.valueOf() / dayMs - 0.5 + J1970;
/**
* convert date from Julian calendar
* @param {*} date object to convert
* @return {date} result date
*/
function fromJulianDay(j) {
return new Date((j - J1970) * dayMs);
}
function fromJulian(j) {
return new Date((j + 0.5 - J1970) * dayMs);
}
/**
* get number of days for a date since 2000
* @param {*} date date to get days
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {number} cont of days
*/
function toDays(date, inUTC) {
date = date || new Date();
if (inUTC === false) {
return ((Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) / dayMs) + J1970) - J2000;
}
return ((date.valueOf() / dayMs) + J1970) - J2000;
// return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()) / dayMs + J1970 - J2000;
function toDays(date) {
return toJulian(date) - J2000;
// return toJulianDay(date) - J2000;
}

@@ -99,5 +113,17 @@

// calculates sun position for a given date and latitude/longitude
/**
* @typedef {Object} sunposition
* @property {number} azimuth - The azimuth of the sun
* @property {number} altitude - The altitude of the sun
*/
SunCalc.getPosition = function (date, lat, lng) {
/**
* calculates sun position for a given date and latitude/longitude
* @param {Date} date Date object with the for calculating sun-position
* @param {number} lat latitude for calculating sun-position
* @param {number} lng longitude for calculating sun-position
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {sunposition} result object of sun-position
*/
SunCalc.getPosition = function (date, lat, lng, inUTC) {
if (isNaN(lat)) {

@@ -112,3 +138,3 @@ throw new Error('latitude missing');

const phi = rad * lat;
const d = toDays(date);
const d = toDays(date, inUTC);
const c = sunCoords(d);

@@ -122,20 +148,69 @@ const H = siderealTime(d, lw) - c.ra;

// sun times configuration (angle, morning name, evening name)
/**
* @typedef {Object} suntime
* @property {string} name - The Name of the time
* @property {Date} value - Date object with the calculated sun-time
* @property {number} pos - The position of the sun on the time
* @property {number} angle - Angle of the sun on the time
*/
/**
* @typedef {Object} suntimes
* @property {suntime} solarNoon - The sun-time for the solar noon (sun is in the highest position)
* @property {suntime} nadir - The sun-time for nadir (darkest moment of the night, sun is in the lowest position)
* @property {suntime} goldenHourDawnStart - The sun-time for morning golden hour (soft light, best time for photography)
* @property {suntime} goldenHourDawnEnd - The sun-time for morning golden hour (soft light, best time for photography)
* @property {suntime} goldenHourDuskStart - The sun-time for evening golden hour starts
* @property {suntime} goldenHourDuskEnd - The sun-time for evening golden hour starts
* @property {suntime} sunriseEnd - The sun-time for sunrise ends (bottom edge of the sun touches the horizon)
* @property {suntime} sunsetStart - The sun-time for sunset starts (bottom edge of the sun touches the horizon)
* @property {suntime} sunrise - The sun-time for sunrise (top edge of the sun appears on the horizon)
* @property {suntime} sunset - The sun-time for sunset (sun disappears below the horizon, evening civil twilight starts)
* @property {suntime} blueHourDawnStart - The sun-time for blue Hour start (time for special photography photos starts)
* @property {suntime} blueHourDawnEnd - The sun-time for blue Hour end (time for special photography photos end)
* @property {suntime} blueHourDuskStart - The sun-time for blue Hour start (time for special photography photos starts)
* @property {suntime} blueHourDuskEnd - The sun-time for blue Hour end (time for special photography photos end)
* @property {suntime} civilDawn - The sun-time for dawn (morning nautical twilight ends, morning civil twilight starts)
* @property {suntime} civilDusk - The sun-time for dusk (evening nautical twilight starts)
* @property {suntime} nauticalDawn - The sun-time for nautical dawn (morning nautical twilight starts)
* @property {suntime} nauticalDusk - The sun-time for nautical dusk end (evening astronomical twilight starts)
* @property {suntime} amateurDawn - The sun-time for amateur astronomical dawn (sun at 12° before sunrise)
* @property {suntime} amateurDusk - The sun-time for amateur astronomical dusk (sun at 12° after sunrise)
* @property {suntime} astronomicalDawn - The sun-time for night ends (morning astronomical twilight starts)
* @property {suntime} astronomicalDusk - The sun-time for night starts (dark enough for astronomical observations)
* @property {suntime} [dawn] - Deprecated: alternate for civilDawn
* @property {suntime} [dusk] - Deprecated: alternate for civilDusk
* @property {suntime} [nightEnd] - Deprecated: alternate for astronomicalDawn
* @property {suntime} [night] - Deprecated: alternate for astronomicalDusk
* @property {suntime} [nightStart] - Deprecated: alternate for astronomicalDusk
* @property {suntime} [goldenHour] - Deprecated: alternate for goldenHourDuskStart
* @property {suntime} [sunsetEnd] - Deprecated: alternate for sunset
* @property {suntime} [sunriseStart] - Deprecated: alternate for sunrise
* @property {suntime} [goldenHourEnd] - Deprecated: alternate for goldenHourDawnEnd
* @property {suntime} [goldenHourStart] - Deprecated: alternate for goldenHourDuskStart
*/
/** sun times configuration (angle, morning name, evening name) */
const sunTimes = SunCalc.times = [
[6, 'goldenHourEnd', 'goldenHourStart', 9, 11], // GOLDEN_HOUR_AM
[-0.3, 'sunriseEnd', 'sunsetStart', 8, 12], // SUNRISE_END
[-0.833, 'sunrise', 'sunset', 7, 13], // SUNRISE
[-4, 'blueHourDawnEnd', 'blueHourDuskStart', 6, 14], // BLUE_HOUR
[-6, 'civilDawn', 'civilDusk', 5, 15], // DAWN
[-8, 'blueHourDawnStart', 'blueHourDuskEnd', 4, 16], // BLUE_HOUR
[-12, 'nauticalDawn', 'nauticalDusk', 3, 17], // NAUTIC_DAWN
[-15, 'amateurDawn', 'amateurDusk', 2, 18],
[-18, 'astronomicalDawn', 'astronomicalDusk', 1, 19] // ASTRO_DAWN
[6, 'goldenHourDawnEnd', 'goldenHourDuskStart', 10, 12], // GOLDEN_HOUR_2
[-0.3, 'sunriseEnd', 'sunsetStart', 9, 13], // SUNRISE_END
[-0.833, 'sunrise', 'sunset', 8, 14], // SUNRISE
[-1, 'goldenHourDawnStart', 'goldenHourDuskEnd', 7, 15], // GOLDEN_HOUR_1
[-4, 'blueHourDawnEnd', 'blueHourDuskStart', 6, 16], // BLUE_HOUR
[-6, 'civilDawn', 'civilDusk', 5, 17], // DAWN
[-8, 'blueHourDawnStart', 'blueHourDuskEnd', 4, 18], // BLUE_HOUR
[-12, 'nauticalDawn', 'nauticalDusk', 3, 19], // NAUTIC_DAWN
[-15, 'amateurDawn', 'amateurDusk', 2, 20],
[-18, 'astronomicalDawn', 'astronomicalDusk', 1, 21] // ASTRO_DAWN
];
/** default time definitions */
const sunTimesDefault = SunCalc.timesDefault = {
solarNoon: 10,
solarNoon: 11,
nadir: 0
};
/** alternate time names for backward compatibility */
const sunTimesAlternate = SunCalc.timesAlternate = [
// for backward compatibility
['dawn', 'civilDawn'],

@@ -146,6 +221,10 @@ ['dusk', 'civilDusk'],

['nightStart', 'astronomicalDusk'],
['goldenHour', 'goldenHourStart']
['goldenHour', 'goldenHourDuskStart'],
['sunriseStart', 'sunrise'],
['sunsetEnd', 'sunset'],
['goldenHourEnd', 'goldenHourDawnEnd'],
['goldenHourStart', 'goldenHourDuskStart']
];
// adds a custom time to the times config
/** adds a custom time to the times config */
SunCalc.addTime = function (angle, riseName, setName, risePos, setPos) {

@@ -175,3 +254,3 @@ sunTimes.push([angle, riseName, setName, risePos, setPos]);

// returns set time for the given sun altitude
/** returns set time for the given sun altitude */
function getSetJ(h, lw, phi, dec, n, M, L) {

@@ -181,8 +260,15 @@ const w = hourAngle(h, phi, dec);

const a = approxTransit(w, lw, n);
// console.log(`h=${h} lw=${lw} phi=${phi} dec=${dec} n=${n} M=${M} L=${L} w=${w} a=${a}`);
return solarTransitJ(a, M, L);
}
// calculates sun times for a given date and latitude/longitude
SunCalc.getTimes = function (date, lat, lng) {
/**
* calculates sun times for a given date and latitude/longitude
* @param {Date} date Date object with the for calculating sun-times
* @param {number} lat latitude for calculating sun-times
* @param {number} lng longitude for calculating sun-times
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {suntimes} result object of sunTime
*/
SunCalc.getSunTimes = function (date, lat, lng, inUTC, noDeprecated) {
if (isNaN(lat)) {

@@ -198,3 +284,3 @@ throw new Error('latitude missing');

const d = toDays(date);
const d = toDays(date, inUTC);
const n = julianCycle(d, lw);

@@ -207,16 +293,26 @@ const ds = approxTransit(0, lw, n);

const noonVal = fromJulianDay(Jnoon);
const nadirVal = fromJulianDay(Jnoon + 0.5);
const result = {
solarNoon: {
value: fromJulian(Jnoon),
solarNoon : {
value: noonVal,
ts: noonVal.getTime(),
pos: sunTimesDefault.solarNoon,
name: 'solarNoon',
angle: 90
angle: 90,
julian: Jnoon,
valid: !isNaN(Jnoon)
},
nadir: {
value: fromJulian(Jnoon + 0.5),
value: nadirVal,
ts: nadirVal.getTime(),
pos: sunTimesDefault.nadir,
name: 'nadir',
angle: 270
angle: 270,
julian: Jnoon + 0.5,
valid: !isNaN(Jnoon)
}
};
result.solarNoon.ts = result.solarNoon.value.getTime();

@@ -226,17 +322,38 @@ result.nadir.ts = result.nadir.value.getTime();

const time = sunTimes[i];
const sa = time[0];
let valid = true;
const Jset = getSetJ(time[0] * rad, lw, phi, dec, n, M, L);
let Jset = getSetJ(sa * rad, lw, phi, dec, n, M, L);
if (isNaN(Jset)) {
Jset = (Jnoon + 0.5);
valid = false;
/* Näherung an Wert
const b = Math.abs(time[0]);
while (isNaN(Jset) && ((Math.abs(sa) - b) < 2)) {
sa += 0.005;
Jset = getSetJ(sa * rad, lw, phi, dec, n, M, L);
} /* */
}
const Jrise = Jnoon - (Jset - Jnoon);
const v1 = fromJulianDay(Jset);
const v2 = fromJulianDay(Jrise);
result[time[2]] = {
value: fromJulian(Jset),
value: v1,
ts: v1.getTime(),
pos: time[4],
name: time[2],
angle: time[0]
angle: sa,
julian: Jset,
valid
};
result[time[1]] = {
value: fromJulian(Jrise),
value: v2,
ts: v2.getTime(),
pos: time[3],
name: time[1],
angle: (180 + (time[0] * -1))
angle: (180 + (sa * -1)),
julian: Jrise,
valid
};

@@ -247,6 +364,8 @@ result[time[2]].ts = result[time[2]].value.getTime();

// for backward compatibility
for (let i = 0, len = sunTimesAlternate.length; i < len; i += 1) {
const time = sunTimesAlternate[i];
result[time[0]] = result[time[1]];
if (!noDeprecated) {
// for backward compatibility
for (let i = 0, len = sunTimesAlternate.length; i < len; i += 1) {
const time = sunTimesAlternate[i];
result[time[0]] = result[time[1]];
}
}

@@ -259,3 +378,7 @@

function moonCoords(d) { // geocentric ecliptic coordinates of the moon
/**
* calculate the geocentric ecliptic coordinates of the moon
* @param {number} d number of days
*/
function moonCoords(d) {
const L = rad * (218.316 + 13.176396 * d);

@@ -285,6 +408,22 @@ // ecliptic longitude

SunCalc.getMoonPosition = function (date, lat, lng) {
/**
* @typedef {Object} moonposition
* @property {number} azimuth - The azimuth of the moon
* @property {number} altitude - The altitude of the moon
* @property {number} distance - The distance of the moon to the earth
* @property {number} parallacticAngle - The parallactic angle of the moon
*/
/**
* calculates moon position for a given date and latitude/longitude
* @param {Date} date Date object with the for calculating moon-position
* @param {number} lat latitude for calculating moon-position
* @param {number} lng longitude for calculating moon-position
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {moonposition} result object of moon-position
*/
SunCalc.getMoonPosition = function (date, lat, lng, inUTC) {
const lw = rad * -lng;
const phi = rad * lat;
const d = toDays(date);
const d = toDays(date, inUTC);
const c = moonCoords(d);

@@ -306,8 +445,19 @@ const H = siderealTime(d, lw) - c.ra;

// calculations for illumination parameters of the moon,
// based on http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and
// Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998.
/**
* @typedef {Object} moonillumination
* @property {number} fraction - The fraction of the moon
* @property {number} phase - The phase of the moon
* @property {number} angle - The angle of the moon
*/
SunCalc.getMoonIllumination = function (date) {
const d = toDays(date || new Date());
/**
* calculations for illumination parameters of the moon,
* based on http://idlastro.gsfc.nasa.gov/ftp/pro/astro/mphase.pro formulas and
* Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998.
* @param {Date} date Date object with the for calculating moon-illumination
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {moonillumination} result object of moon-illumination
*/
SunCalc.getMoonIllumination = function (date, inUTC) {
const d = toDays(date, inUTC);

@@ -339,10 +489,24 @@ const s = sunCoords(d);

// calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article
/**
* @typedef {Object} moontimes
* @property {Date} rise - a Date object if the moon is rising on the given Date, otherwhise NaN
* @property {Date} set - a Date object if the moon is setting on the given Date, otherwhise NaN
* @property {boolean} [alwaysUp] - is true if the moon in always up, oitherwise property not exists
* @property {boolean} [alwaysDown] - is true if the moon in always up, oitherwise property not exists
*/
/**
* calculations for moon rise/set times are based on http://www.stargazing.net/kepler/moonrise.html article
* @param {Date} date Date object with the for calculating moon-times
* @param {number} lat latitude for calculating moon-times
* @param {number} lng longitude for calculating moon-times
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is UTC)
* @return {moontimes} result object of sunTime
*/
SunCalc.getMoonTimes = function (date, lat, lng, inUTC) {
const t = new Date(date);
if (inUTC) {
if (inUTC === false) {
t.setHours(0, 0, 0, 0);
} else {
t.setUTCHours(0, 0, 0, 0);
} else {
t.setHours(0, 0, 0, 0);
}

@@ -349,0 +513,0 @@ // console.log(`getMoonTimes lat=${lat} lng=${lng} inUTC=${inUTC} date=${date} t=${t}`);

@@ -77,3 +77,4 @@ {

"UTC Datum und Zeit",
"ISO Datum und Zeit",
"ISO Datum und Zeit UTC",
"ISO Datum und Zeit Lokal",
"Millisekunden",

@@ -253,6 +254,8 @@ "Sekunden",

"angleType": "Winkel Typ",
"timezoneOffset": "Zeitzone",
"timeZoneOffset": "Zeitzone",
"name": "Name",
"property": "Property",
"minutes": "Minuten"
"minutes": "Minuten",
"stateDateFormat": "Status-Datums Format",
"stateTimeFormat": "Status-Zeit Format"
},

@@ -264,8 +267,11 @@ "placeholder": {

"angleType": "deg",
"timezoneOffset": "0",
"name": "Name"
"timeZoneOffset": "0",
"name": "Name",
"stateDateFormat": "Format der Statusausgabe eines Datums. Standard ist toLocale​Date​String.",
"stateTimeFormat": "Format der Statusausgabe einer Uhrzeit. Standard ist toLocale​Time​String."
},
"tips": {
"config": "Starting from Version 2.0 the coordinates are not saved as credentials due to privacy reasons. So they no longer part of the regular flow and will not part of the export! To update from a previous version save and re-deploy is necessary.",
"sunPosControl": "Here you can specify the upper and lower limits for the solar radiation so that you can evaluate the sunshine on 4 sides of an object."
"sunPosControl": "Here you can specify the upper and lower limits for the solar radiation so that you can evaluate the sunshine on 4 sides of an object.",
"stateFormat":"Änderungen am Format können einige zeit dauern, bis diese Auswirkung zeigen."
},

@@ -272,0 +278,0 @@ "errors": {

@@ -77,3 +77,4 @@ {

"UTC date and time",
"ISO date and time",
"ISO date and time UTC",
"ISO date and time local",
"milliseconds",

@@ -222,4 +223,5 @@ "seconds",

"isoDate": "yyyy-MM-dd",
"isoTime": "HH:MM:ss",
"isoDateTime": "yyyy-MM-dd'T'HH:mm:ss",
"isoTime": "HH:mm:ss",
"isoTimeZ": "HH:mm:ssooo",
"isoDateTime": "yyyy-MM-dd'T'HH:mm:ssooo",
"isoUtcDateTime": "UTC:yyyy-MM-dd'T'HH:mm:ss'Z'"

@@ -256,4 +258,4 @@ },

"pos-config-state": "Node not properly configured!!",
"unknownPropertyOperator": "error, the unsed property operator __propertyOp__=\"__propertyOpText__\" is unknown!",
"unknownCompareOperator": "error, the unsed compare operator \"__operator__\" is unknown!",
"unknownPropertyOperator": "error, the used property operator __propertyOp__=\"__propertyOpText__\" is unknown!",
"unknownCompareOperator": "error, the used compare operator \"__operator__\" is unknown!",
"notEvaluableProperty":"Error: could not evaluate __type__.__value__!",

@@ -268,6 +270,8 @@ "notEvaluablePropertyAdd":"Error \"__err__\", could not evaluate __type__.__value__"

"angleType": "angle type",
"timezoneOffset": "TZ Offset",
"timeZoneOffset": "TZ Offset",
"name": "Name",
"property": "Property",
"minutes": "minutes"
"minutes": "minutes",
"stateDateFormat": "State Date Format",
"stateTimeFormat": "State Time Format"
},

@@ -279,8 +283,11 @@ "placeholder": {

"angleType": "deg",
"timezoneOffset": "0",
"name": "Name"
"timeZoneOffset": "0",
"name": "Name",
"stateDateFormat": "Format of the state output of a date only. If empty default toLocale​Date​String will be used.",
"stateTimeFormat": "Format of the state output of a time only. If empty default toLocale​Time​String will be used."
},
"tips": {
"config": "Starting from Version 2.0 the coordinates are not saved as credentials due to privacy reasons. So they no longer part of the regular flow and will not part of the export! To update from a previous version save and re-deploy is necessary.",
"sunPosControl": "Here you can specify the upper and lower limits for the solar radiation so that you can evaluate the sunshine on 4 sides of an object."
"sunPosControl": "Here you can specify the upper and lower limits for the solar radiation so that you can evaluate the sunshine on 4 sides of an object.",
"stateFormat":"Formatchanges to time could taken time until it will get any effect."
},

@@ -287,0 +294,0 @@ "errors": {

@@ -85,3 +85,3 @@ /********************************************

const altitude = (ports[0].payload.altitude) ? ports[0].payload.altitude.toFixed(2) : '?';
text = azimuth + '/' + altitude + ' - ' + ports[0].payload.lastUpdate.toLocaleString();
text = azimuth + '/' + altitude + ' - ' + node.positionConfig.dateToString(ports[0].payload.lastUpdate);
fill = 'grey';

@@ -88,0 +88,0 @@ }

@@ -85,3 +85,10 @@ /********************************************

this.angleType = config.angleType;
this.tzOffset = (config.timezoneOffset * -60) || 0;
this.tzOffset = (config.timeZoneOffset || 99);
if (isNaN(this.tzOffset) || this.tzOffset > 99 || this.tzOffset < -99) {
this.tzOffset = 99;
}
this.tzOffset = (this.tzOffset * -60);
this.stateTimeFormat = config.stateTimeFormat || '3';
this.stateDateFormat = config.stateDateFormat || '12';
// this.debug('load position-config ' + this.name + ' long:' + this.longitude + ' latitude:' + this.latitude + ' angelt:' + this.angleType + ' TZ:' + this.tzOffset);

@@ -113,4 +120,4 @@ this.lastSunCalc = {

/**
*
* @param node
* register a node as child
* @param node node to register as child node
*/

@@ -122,6 +129,6 @@ register(node) {

/**
*
* @param node
* @param done
* @returns {*}
* remove a previous registered node as child
* @param node node to remove
* @param done function which should be executed after deregister
* @returns {function}
*/

@@ -133,4 +140,20 @@ deregister(node, done) {

/*******************************************************************************************************/
/**
* @typedef {Object} timeresult
* @property {Date} value - a Date object of the neesed date/time
* @property {string} [error] - string of an error message if an error occurs
*/
/**
* gets sun time
* @param {Date} now current time
* @param {string} value name of the sun time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the sun time
* @return {timeresult} result object of sunTime
*/
getSunTime(now, value, offset, multiplier, next, days) {
// this.debug('getSunTime value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
this.debug('getSunTime value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
let result = this._sunTimesCheck(now);

@@ -145,3 +168,3 @@ result = Object.assign(result, this.sunTimesToday[value]);

const date = (new Date()).addDays(next);
result = Object.assign(result, sunCalc.getTimes(date, this.latitude, this.longitude)[value]);
result = Object.assign(result, sunCalc.getSunTimes(date, this.latitude, this.longitude)[value]);
}

@@ -158,4 +181,3 @@

const date = result.value.addDays(dayx);
// let times = sunCalc.getTimes(date, this.latitude, this.longitude);
result = Object.assign(result, sunCalc.getTimes(date, this.latitude, this.longitude)[value]);
result = Object.assign(result, sunCalc.getSunTimes(date, this.latitude, this.longitude)[value]);
result.value = hlp.addOffset(new Date(result.value), offset, multiplier);

@@ -168,6 +190,16 @@ } else if (dayx < 0) {

// this.debug('getSunTime result=' + util.inspect(result));
this.debug('getSunTime result=' + util.inspect(result));
return result;
}
/*******************************************************************************************************/
/**
* gets moon time
* @param {Date} now current time
* @param {string} value name of the moon time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the moon time
* @return {timeresult} result object of moon time
*/
getMoonTime(now, value, offset, multiplier, next, days) {

@@ -183,3 +215,3 @@ // this.debug('getMoonTime value=' + value + ' offset=' + offset + ' next=' + next + ' days=' + days);

const date = (new Date()).addDays(next);
const times = sunCalc.getMoonTimes(date, this.latitude, this.longitude, true);
const times = sunCalc.getMoonTimes(date, this.latitude, this.longitude);
result.value = hlp.addOffset(new Date(times[value]), offset, multiplier);

@@ -194,3 +226,3 @@ }

const date = (new Date()).addDays(dayx);
const times = sunCalc.getMoonTimes(date, this.latitude, this.longitude, true);
const times = sunCalc.getMoonTimes(date, this.latitude, this.longitude);
result.value = hlp.addOffset(new Date(times[value]), offset, multiplier);

@@ -208,2 +240,45 @@ } else if (dayx < 0) {

/*******************************************************************************************************/
/**
* Formate a Date Object to a Date and Time String
* @param {Date} dt Date to format to Date and Time string
* @returns {string} formated Date object
*/
dateToString(dt) {
return (this.dateToDateString(dt) + ' ' + this.dateToTimeString(dt)).trim();
}
/**
* Formate a Date Object to a Time String
* @param {Date} dt Date to format to trime string
* @returns {string} formated Date object
*/
dateToTimeString(dt) {
if (this.stateTimeFormat === '3') {
return dt.toLocaleTimeString();
}
return hlp.getFormattedDateOut(dt, this.stateTimeFormat);
}
/**
* Formate a Date Object to a Date String
* @param {Date} dt Date to format to Date string
* @returns {string} formated Date object
*/
dateToDateString(dt) {
if (this.stateDateFormat === '12') {
return dt.toLocaleDateString();
}
return hlp.getFormattedDateOut(dt, this.stateDateFormat);
}
/*******************************************************************************************************/
/**
* get a float value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {string} type - type name of the type input
* @param {*} value - value of the type input
* @param {*} [def] - default value if can not get float value
* @param {*} [opCallback] - callback function for getting getPropValue
* @returns {number} float property
*/
getFloatProp(_srcNode, msg, type, value, def, opCallback) {

@@ -253,6 +328,6 @@ // _srcNode.debug('getFloatProp type='+type+' value='+value);

const offsetX = this.getFloatProp(_srcNode, msg, offsetType, offset, 0);
result = this.getSunTime((new Date()), value, offsetX, multiplier, undefined, days);
result = this.getSunTime((new Date()), value, offsetX, multiplier, 1, days);
} else if (vType === 'pdmTime') { // moon
const offsetX = this.getFloatProp(_srcNode, msg, offsetType, offset, 0);
result = this.getMoonTime((new Date()), value, offsetX, multiplier, undefined, days);
result = this.getMoonTime((new Date()), value, offsetX, multiplier, 1, days);
}

@@ -335,3 +410,3 @@ if (result && result.value && !result.error) {

getTimeProp(_srcNode, msg, vType, value, offsetType, offset, multiplier, next, days) {
// this.debug('getTimeProp [' + hlp.getNodeId(_srcNode) + '] vType=' + vType + ' value=' + value + ' offset=' + offset + ' offsetType=' + offsetType + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
this.debug('getTimeProp [' + hlp.getNodeId(_srcNode) + '] vType=' + vType + ' value=' + value + ' offset=' + offset + ' offsetType=' + offsetType + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
let result = {

@@ -402,2 +477,12 @@ value: null,

/*******************************************************************************************************/
/**
* get a property value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {string} type - type name of the type input
* @param {*} value - value of the type input
* @param {function} [callback] - function which should be called after value was recived
* @param {*} [addID] - additional parameter for the callback
* @returns {*} value of the type input, return of the callback function if defined or __null__ if value could not resolved
*/
getPropValue(_srcNode, msg, type, value, callback, addID) {

@@ -663,4 +748,4 @@ // _srcNode.debug(`getPropValue ${type}.${value} (${addID})`);

// this.debug('sunTimesRefresh - calculate sun times');
this.sunTimesToday = sunCalc.getTimes(today, this.latitude, this.longitude);
this.sunTimesTomorow = sunCalc.getTimes(tomorrow, this.latitude, this.longitude);
this.sunTimesToday = sunCalc.getSunTimes(today, this.latitude, this.longitude);
this.sunTimesTomorow = sunCalc.getSunTimes(tomorrow, this.latitude, this.longitude);
this.sunDayId = dayId;

@@ -687,3 +772,3 @@ }

// this.debug('moonTimesRefresh - calculate moon times');
this.moonTimesToday = sunCalc.getMoonTimes(today, this.latitude, this.longitude, true);
this.moonTimesToday = sunCalc.getMoonTimes(today, this.latitude, this.longitude);
if (!this.moonTimesToday.alwaysUp) {

@@ -699,3 +784,3 @@ // true if the moon never rises/sets and is always above the horizon during the day

this.moonTimesTomorow = sunCalc.getMoonTimes(tomorrow, this.latitude, this.longitude, true);
this.moonTimesTomorow = sunCalc.getMoonTimes(tomorrow, this.latitude, this.longitude);
if (!this.moonTimesTomorow.alwaysUp) {

@@ -702,0 +787,0 @@ // true if the moon never rises/sets and is always above the horizon during the day

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

{id: 5, group: 'string', name: 'ISO', label: 'ISO date and time'},
{id: 18, group: 'string', name: 'ISO-2', label: 'ISO date and time of local timezone' },
{id: 6, group: 'time', name: 'ms', label: 'milliseconds'},

@@ -215,4 +216,5 @@ {id: 7, group: 'time', name: 'sec', label: 'seconds'},

options: [ 'astronomicalDawn', 'amateurDawn', 'nauticalDawn', 'blueHourDawnStart', 'civilDawn', 'blueHourDawnEnd',
'sunrise', 'sunriseEnd', 'goldenHourEnd', 'solarNoon', 'goldenHourStart', 'sunsetStart', 'sunset', 'blueHourDuskStart',
'civilDusk', 'blueHourDuskEnd', 'amateurDusk', 'astronomicalDusk', 'nadir']
'goldenHourDawnStart', 'sunrise', 'sunriseEnd', 'goldenHourDawnEnd', 'solarNoon', 'goldenHourDuskStart',
'sunsetStart', 'sunset', 'goldenHourDuskEnd', 'blueHourDuskStart', 'civilDusk', 'blueHourDuskEnd',
'nauticalDusk', 'amateurDusk', 'astronomicalDusk', 'nadir']
},

@@ -509,39 +511,32 @@ TimeMoon: {

function initCombobox(node, inputSelectName, inputBoxName, dataList, optionElementName, value, width) { // eslint-disable-line no-unused-vars
// console.log('initCombobox node=' + node + ' inputSelectName=' + inputSelectName + ' inputBoxName=' + inputBoxName + ' dataList=' + dataList + ' optionElementName=' + optionElementName + ' value=' + value + ' width=' + width); // eslint-disable-line
const $inputSelect = $('#node-input-' + inputSelectName);
const $inputBox = $('#node-input-' + inputBoxName);
$inputSelect.attr('base-width', width);
$inputSelect.attr('linked-input', inputBoxName);
function initCombobox(node, $inputSelect, $inputBox, dataList, optionElementName, value, baseWidth, timeFormat) { // eslint-disable-line no-unused-vars
// console.log('initCombobox node=' + node + ' dataList=' + dataList + ' optionElementName=' + optionElementName + ' value=' + value + ' width=' + width); // eslint-disable-line
appendOptions(node, $inputSelect, optionElementName);
autocomplete($('#node-input-' + inputBoxName), dataList);
autocomplete($inputBox, dataList);
const valueNum = Number(value);
timeFormat = timeFormat || 'default';
if (isNaN(valueNum)) {
$inputSelect.val(99);
$inputBox.val(value);
} else {
$inputSelect.val(valueNum);
}
$inputSelect.on('change', (_type, _value) => {
// const $inputSelect = $( this ); // $('#node-input-' + inputSelectName);
const inputBoxName = $inputSelect.attr('linked-input');
let width = Number($inputSelect.attr('base-width'));
const $inputBox = $('#node-input-' + inputBoxName);
if (Number($inputSelect.val()) === 99) {
$inputSelect.css({width: '100px'});
width = (205 + width);
$inputBox.css({width: 'calc(100% - ' + width + 'px)'});
$inputSelect.css({ width: '100px' });
const width = (205 + baseWidth);
$inputBox.css({ width: 'calc(100% - ' + width + 'px)' });
$inputBox.show();
if (!isNaN($inputBox.val())) {
$inputBox.val(node._('node-red-contrib-sun-position/position-config:common.timeFormat.default'));
$inputBox.val(node._('node-red-contrib-sun-position/position-config:common.timeFormat.' + timeFormat));
}
} else {
$inputBox.hide();
width = (100 + width);
$inputSelect.css({width: 'calc(100% - ' + width + 'px)'});
const width = (100 + baseWidth);
$inputSelect.css({ width: 'calc(100% - ' + width + 'px)' });
$inputBox.val($inputSelect.val());
}
});
if (value && isNaN(value)) {
$inputSelect.val(99);
$inputBox.val(value);
} else {
$inputSelect.val(Number(value));
}
$inputSelect.change();

@@ -548,0 +543,0 @@ }

@@ -120,4 +120,4 @@ /********************************************

shape: 'dot',
text: new Date(ports[0].payload.startTime).toLocaleTimeString() + ' - ' +
new Date(ports[0].payload.endTime).toLocaleTimeString()
text: node.positionConfig.dateToTimeString(new Date(ports[0].payload.startTime)) + ' - ' +
node.positionConfig.dateToTimeString(new Date(ports[0].payload.endTime))
});

@@ -128,4 +128,4 @@ } else {

shape: 'dot',
text: new Date(ports[0].payload.startTime).toLocaleTimeString() + ' - ' +
new Date(ports[0].payload.endTime).toLocaleTimeString()
text: node.positionConfig.dateToTimeString(new Date(ports[0].payload.startTime)) + ' - ' +
node.positionConfig.dateToTimeString(new Date(ports[0].payload.endTime))
});

@@ -140,3 +140,3 @@ }

const altitude = (ports[0].payload.altitude) ? ports[0].payload.altitude.toFixed(2) : '?';
text = azimuth + '/' + altitude + ' - ' + ports[0].payload.lastUpdate.toLocaleString();
text = azimuth + '/' + altitude + ' - ' + node.positionConfig.dateToString(ports[0].payload.lastUpdate);
fill = 'grey';

@@ -143,0 +143,0 @@ }

@@ -224,3 +224,3 @@ /********************************************

shape: 'ring',
text: node.nextTimeAlt.toLocaleString() + ' / ' + node.nextTime.toLocaleTimeString()
text: node.positionConfig.dateToString(node.nextTimeAlt) + ' / ' + node.positionConfig.dateToTimeString(node.nextTime)
});

@@ -231,3 +231,3 @@ } else {

shape: 'dot',
text: node.nextTime.toLocaleString() + ' / ' + node.nextTimeAlt.toLocaleTimeString()
text: node.positionConfig.dateToString(node.nextTime) + ' / ' + node.positionConfig.dateToTimeString(node.nextTimeAlt)
});

@@ -239,3 +239,3 @@ }

shape: 'dot',
text: node.nextTime.toLocaleString()
text: node.positionConfig.dateToString(node.nextTime)
});

@@ -242,0 +242,0 @@ } else {

@@ -77,3 +77,3 @@ /********************************************

shape: 'dot',
text: '⏲ ⏵' + result.start.value.toLocaleTimeString() + result.startSuffix + ' - ⏴' + result.end.value.toLocaleTimeString() + result.endSuffix
text: '⏲ ⏵' + node.positionConfig.dateToTimeString(result.start.value) + result.startSuffix + ' - ⏴' + node.positionConfig.dateToTimeString(result.end.value) + result.endSuffix
});

@@ -240,3 +240,3 @@ } else {

shape: 'ring',
text: '🖅 ' + result.startSuffix + now.toLocaleString() + result.endSuffix
text: '🖅 ' + result.startSuffix + node.positionConfig.dateToString(now) + result.endSuffix
}, false);

@@ -252,3 +252,3 @@ checkReSendMsgDelayed(config.lastMsgOnEndOut, this, result.end.value, msg);

shape: 'dot',
text: '🖅 ' + result.startSuffix + now.toLocaleString() + result.endSuffix
text: '🖅 ' + result.startSuffix + node.positionConfig.dateToString(now) + result.endSuffix
}, false);

@@ -264,3 +264,3 @@ checkReSendMsgDelayed(config.lastMsgOnEndOut, this, result.end.value, msg);

shape: 'dot',
text: '⛔' + result.startSuffix + now.toLocaleString() + result.endSuffix
text: '⛔' + result.startSuffix + node.positionConfig.dateToString(now) + result.endSuffix
}, false);

@@ -267,0 +267,0 @@ checkReSendMsgDelayed(config.lastMsgOnStartOut, this, result.start.value, msg);

{
"name": "node-red-contrib-sun-position",
"version": "0.3.1",
"version": "0.3.2",
"description": "NodeRED nodes to get sun and moon position",

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

@@ -130,5 +130,5 @@ # node-red-contrib-sun-position for NodeRED

* `msg.payload.times.sunriseEnd` sunrise ends (bottom edge of the sun touches the horizon)
* `msg.payload.times.goldenHourEnd` morning golden hour (soft light, best time for photography) ends
* `msg.payload.times.goldenHourDawnEnd` morning golden hour (soft light, best time for photography) ends
* `msg.payload.times.solarNoon` solar noon (sun is in the highest position)
* `msg.payload.times.goldenHourStart` evening golden hour starts
* `msg.payload.times.goldenHourDuskStart` evening golden hour starts
* `msg.payload.times.sunsetStart` sunset starts (bottom edge of the sun touches the horizon)

@@ -175,4 +175,4 @@ * `msg.payload.times.sunset` sunset (sun disappears below the horizon, evening civil twilight starts)

"astronomicalDusk":"2018-12-10T17:01:39.696Z",
"goldenHourEnd":"2018-12-10T07:58:28.541Z",
"goldenHourStart":"2018-12-10T14:00:01.086Z",
"goldenHourDawnEnd":"2018-12-10T07:58:28.541Z",
"goldenHourDuskStart":"2018-12-10T14:00:01.086Z",
"dawn":"2018-12-10T06:19:31.249Z",

@@ -469,3 +469,3 @@ "dusk":"2018-12-10T15:38:58.379Z",

following Sun times can be chosen:
following Sun times will be calculated and can be chosen:

@@ -480,9 +480,11 @@ | Time | Description | SunBH |

| `blueHourDawnEnd` | blue Hour end (time for special photography photos end) | 4 |
| `goldenHourDawnStart` | morning golden hour (soft light, best time for photography) starts | -1 |
| `sunrise` | sunrise (top edge of the sun appears on the horizon) | 0.833 |
| `sunriseEnd` | sunrise ends (bottom edge of the sun touches the horizon) | 0.3 |
| `goldenHourEnd` | morning golden hour (soft light, best time for photography) ends | -6 |
| `goldenHourDawnEnd` | morning golden hour (soft light, best time for photography) ends | -6 |
| `solarNoon` | solar noon (sun is in the highest position) | |
| `goldenHourStart` | evening golden hour starts | -6 |
| `goldenHourDuskStart` | evening golden hour (soft light, best time for photography) starts | -6 |
| `sunsetStart` | sunset starts (bottom edge of the sun touches the horizon) | 0.3 |
| `sunset` | sunset (sun disappears below the horizon, evening civil twilight starts) | 0.833 |
| `goldenHourDuskEnd` | evening golden hour (soft light, best time for photography) ends | 1 |
| `blueHourDuskStart` | blue Hour start (time for special photography photos starts) | 4 |

@@ -514,10 +516,14 @@ | `civilDusk` | dusk (evening nautical twilight starts) | 6 |

| time parameter | is equal to |
| -------------- | ------------------ |
| `dawn` | `civilDawn` |
| `dusk` | `civilDusk` |
| `nightEnd` | `astronomicalDawn` |
| `night` | `astronomicalDusk` |
| `nightStart` | `astronomicalDusk` |
| `goldenHour` | `goldenHourStart` |
| time parameter | is equal to |
| ----------------- | ------------------------ |
| `dawn` | `civilDawn` |
| `dusk` | `civilDusk` |
| `nightEnd` | `astronomicalDawn` |
| `night` | `astronomicalDusk` |
| `nightStart` | `astronomicalDusk` |
| `goldenHour` | `goldenHourDuskStart` |
| `sunsetEnd` | `sunset` |
| `sunriseStart` | `sunrise` |
| `goldenHourEnd` | `goldenHourDawnEnd` |
| `goldenHourStart` | `goldenHourDuskStart` |

@@ -647,4 +653,9 @@ #### moon times

| TT | Uppercase, two-character time marker string: AM or PM. |
| Z | US timezone abbreviation, e.g. EST or MDT. With non-US time zones or in the Opera browser, the GMT/UTC offset is returned, e.g. GMT-0500 |
| o | GMT/UTC timezone offset, e.g. -0500 or +0230. |
| Z | timezone abbreviation, e.g. EST, MDT, MESZ or MEZ. |
| z | timezone offset, e.g. GMT-0500 |
| zz | timezone offset - nothing for GMT/UTC, e.g. -0500 or +0230. |
| o | GMT/UTC timezone offset in hours:minutes, e.g. -05:00 or +02:30. |
| oo | GMT/UTC timezone offset, e.g. -0500 or +0230. |
| ooo | GMT/UTC timezone offset - 'Z' for GMT/UTC, e.g. -0500 or +0230. |
| oooo | GMT/UTC timezone offset - 'UTC' for GMT/UTC, e.g. -0500 or +0230. |
| S | The date's ordinal suffix (st, nd, rd, or th). Works well with d. |

@@ -651,0 +662,0 @@ | x | difference of days from timestamp day to output day |

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc