Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var varIndicators = indicators[varName];
for(var valueName in varIndicators) {
var indicator = varIndicators[valueName];
var sDate = date.parse(indicator.start.stamp,
indicator.start.format);
var eDate = date.parse(indicator.end.stamp,
indicator.end.format)
var fromDate = date.parse(fromT.stamp, fromT.format);
var toDate = date.parse(toT.stamp, toT.format);
var pDuration = indicator.period ? new Duration(indicator.period) : undefined;
if (pDuration) {
interval = findPeriodicalIntervalFor(fromDate, sDate, eDate, pDuration);
var period = pDuration.milliseconds();
if (!isInInterval(interval.sDate, fromDate, toDate) &&
!isInInterval(interval.eDate, fromDate, toDate) ) {
sDate = date.addMilliseconds(interval.sDate, period);
eDate = date.addMilliseconds(interval.eDate, period);
} else if (isInInterval(date.addMilliseconds(interval.eDate, -period), fromDate, toDate)) {
sDate = date.addMilliseconds(interval.sDate, -period);
eDate = date.addMilliseconds(interval.eDate, -period);
} else {
sDate = interval.sDate;
eDate = interval.eDate;
}
}
do {
var lDatePoint = sDate;
var rDatePoint = eDate;
if (!isInInterval(lDatePoint, fromDate, toDate) &&
!isInInterval(rDatePoint, fromDate, toDate) &&
i--;
for(; i < distr.length; i++) {
var fromStart = new Duration(distr[i].fromStart).milliseconds();
iDate = date.addMilliseconds(sDate, fromStart);
if (isInInterval(iDate, lDatePoint, rDatePoint)) {
timePointsSet.add(iDate.getTime());
} else {
break;
}
}
}
if (pDuration) {
var period = pDuration.milliseconds();
sDate = date.addMilliseconds(sDate, period);
eDate = date.addMilliseconds(eDate, period);
}
} while(pDuration && isInInterval(sDate, fromDate, toDate));
}
}
var timePointsArray = [];
timePointsSet.forEach(v => timePointsArray.push(v));
return timePointsArray;
}
timePointsSet.add(lDatePoint.getTime());
timePointsSet.add(rDatePoint.getTime());
if (indicator.distribution) {
var distr = indicator.distribution;
var i = 0;
var iDate;
do {
var fromStart = new Duration(distr[i].fromStart).milliseconds();
iDate = date.addMilliseconds(sDate, fromStart);
} while(++i < distr.length && date.subtract(iDate, lDatePoint).toMilliseconds() <= 0);
i--;
for(; i < distr.length; i++) {
var fromStart = new Duration(distr[i].fromStart).milliseconds();
iDate = date.addMilliseconds(sDate, fromStart);
if (isInInterval(iDate, lDatePoint, rDatePoint)) {
timePointsSet.add(iDate.getTime());
} else {
break;
}
}
}
if (pDuration) {
var period = pDuration.milliseconds();
sDate = date.addMilliseconds(sDate, period);
eDate = date.addMilliseconds(eDate, period);
}
} while(pDuration && isInInterval(sDate, fromDate, toDate));
}
}
var timePointsArray = [];
var findPeriodicalIntervalFor = function(tDate, sDate, eDate, pDuration) {
var period = pDuration.milliseconds();
var difference = date.subtract(tDate, sDate).toMilliseconds();
var remainder = difference % period;
var offset = difference - remainder;
offset += remainder >= 0 ? 0 : - period;
var result = {};
result.sDate = date.addMilliseconds(sDate, offset);
result.eDate = date.addMilliseconds(eDate, offset);
return result;
}
var findPeriodicalIntervalFor = function(tDate, sDate, eDate, pDuration) {
var period = pDuration.milliseconds();
var difference = date.subtract(tDate, sDate).toMilliseconds();
var remainder = difference % period;
var offset = difference - remainder;
offset += remainder >= 0 ? 0 : - period;
var result = {};
result.sDate = date.addMilliseconds(sDate, offset);
result.eDate = date.addMilliseconds(eDate, offset);
return result;
}
var sDate = date.parse(indicator.start.stamp,
indicator.start.format);
var eDate = date.parse(indicator.end.stamp,
indicator.end.format)
var fromDate = date.parse(fromT.stamp, fromT.format);
var toDate = date.parse(toT.stamp, toT.format);
var pDuration = indicator.period ? new Duration(indicator.period) : undefined;
if (pDuration) {
interval = findPeriodicalIntervalFor(fromDate, sDate, eDate, pDuration);
var period = pDuration.milliseconds();
if (!isInInterval(interval.sDate, fromDate, toDate) &&
!isInInterval(interval.eDate, fromDate, toDate) ) {
sDate = date.addMilliseconds(interval.sDate, period);
eDate = date.addMilliseconds(interval.eDate, period);
} else if (isInInterval(date.addMilliseconds(interval.eDate, -period), fromDate, toDate)) {
sDate = date.addMilliseconds(interval.sDate, -period);
eDate = date.addMilliseconds(interval.eDate, -period);
} else {
sDate = interval.sDate;
eDate = interval.eDate;
}
}
do {
var lDatePoint = sDate;
var rDatePoint = eDate;
if (!isInInterval(lDatePoint, fromDate, toDate) &&
!isInInterval(rDatePoint, fromDate, toDate) &&
!isInInterval(fromDate, lDatePoint, rDatePoint)) {
break;
}
lDatePoint = fromDate;
}
if (!isInInterval(rDatePoint, fromDate, toDate)) {
rDatePoint = toDate;
}
timePointsSet.add(lDatePoint.getTime());
timePointsSet.add(rDatePoint.getTime());
if (indicator.distribution) {
var distr = indicator.distribution;
var i = 0;
var iDate;
do {
var fromStart = new Duration(distr[i].fromStart).milliseconds();
iDate = date.addMilliseconds(sDate, fromStart);
} while(++i < distr.length && date.subtract(iDate, lDatePoint).toMilliseconds() <= 0);
i--;
for(; i < distr.length; i++) {
var fromStart = new Duration(distr[i].fromStart).milliseconds();
iDate = date.addMilliseconds(sDate, fromStart);
if (isInInterval(iDate, lDatePoint, rDatePoint)) {
timePointsSet.add(iDate.getTime());
} else {
break;
}
}
}
if (pDuration) {
var period = pDuration.milliseconds();
sDate = date.addMilliseconds(sDate, period);
indicator.start.format);
var eDate = date.parse(indicator.end.stamp,
indicator.end.format)
var fromDate = date.parse(fromT.stamp, fromT.format);
var toDate = date.parse(toT.stamp, toT.format);
var pDuration = indicator.period ? new Duration(indicator.period) : undefined;
if (pDuration) {
interval = findPeriodicalIntervalFor(fromDate, sDate, eDate, pDuration);
var period = pDuration.milliseconds();
if (!isInInterval(interval.sDate, fromDate, toDate) &&
!isInInterval(interval.eDate, fromDate, toDate) ) {
sDate = date.addMilliseconds(interval.sDate, period);
eDate = date.addMilliseconds(interval.eDate, period);
} else if (isInInterval(date.addMilliseconds(interval.eDate, -period), fromDate, toDate)) {
sDate = date.addMilliseconds(interval.sDate, -period);
eDate = date.addMilliseconds(interval.eDate, -period);
} else {
sDate = interval.sDate;
eDate = interval.eDate;
}
}
do {
var lDatePoint = sDate;
var rDatePoint = eDate;
if (!isInInterval(lDatePoint, fromDate, toDate) &&
!isInInterval(rDatePoint, fromDate, toDate) &&
!isInInterval(fromDate, lDatePoint, rDatePoint)) {
break;
}