How to use the date-and-time.subtract function in date-and-time

To help you get started, we’ve selected a few date-and-time examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kpi-wdc / dj / dj-libs / bayes-simulator / index.js View on Github external
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;
}
github kpi-wdc / dj / wdc_libs / parsers / ch-ftp / aggregate.js View on Github external
.orderBy(function (a, b) {
	          	if(util.isDate(a.id)){
	          		return (
	          			(date.subtract(new Date(a.id), new Date(b.id)).toMilliseconds()<0)
	          				? -1
	          				: 1
	          		)		
	          	}
	          	if(util.isString(a.id)){
	          		String.naturalCompare(a.id.toLowerCase(),b.id.toLowerCase())
	          	}

	            return a.id - b.id
	          })
	          .get();
github kpi-wdc / dj / wdc_libs / wdc-log.js View on Github external
function(a,b){
          return date.subtract(new Date(a.timeStamp), new Date(b.timeStamp)).toMilliseconds();
    })
    return this;
github kpi-wdc / dj / dj-libs / bayes-simulator / index.js View on Github external
var isInInterval = function(tDate, sDate, eDate) {
	return date.subtract(tDate, sDate).toMilliseconds() >= 0 &&
			date.subtract(tDate, eDate).toMilliseconds() < 0;
}
github kpi-wdc / dj / dj-libs / script / impl / table / order.js View on Github external
"Z-A": function(a, b) {
            return date.subtract(new Date(b), new Date(a)).toMilliseconds();
        }
    }
github kpi-wdc / dj / dj-libs / bayes-simulator / index.js View on Github external
}

				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);
					eDate = date.addMilliseconds(eDate, period);
github raffaelecalza / transmission-telegram-bot / bot / formatter.js View on Github external
Handlebars.registerHelper('differenceBeetwenDates', (firstDate, secondDate) => {
    let seconds = DateTime.subtract(secondDate, firstDate).toSeconds();
    let string = '';
    let sec_num = parseInt(seconds, 10);
    let hours = Math.floor(sec_num / 3600);
    let minutes = Math.floor((sec_num - (hours * 3600)) / 60);
    seconds = sec_num - (hours * 3600) - (minutes * 60);

    if (hours > 0)
        string += hours + ' hours, ';
    if (minutes > 0)
        string += minutes + ' minutes, ';
    if (seconds > 0)
        string += seconds + ' seconds';
    if (string.length == 0)
        string = 'Time not available';
    return string;
})
github kpi-wdc / dj / dj-libs / bayes-simulator / index.js View on Github external
var isInInterval = function(tDate, sDate, eDate) {
	return date.subtract(tDate, sDate).toMilliseconds() >= 0 &&
			date.subtract(tDate, eDate).toMilliseconds() < 0;
}
github kpi-wdc / dj / wdc_libs / data-processing / table / order.js View on Github external
"Z-A": function(a,b){
			return date.subtract(new Date(b), new Date(a)).toMilliseconds();
		}
	}