How to use the es5-ext/date/#/copy.call function in es5-ext

To help you get started, we’ve selected a few es5-ext 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 medikoo / duration / test / index.js View on Github external
"Hours": function (a) {
			// 4 hours 7 minutes 12 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 12);
			d2.setMinutes(d2.getMinutes() + 7);
			d2.setHours(d2.getHours() + 4);

			d = t(d1, d2);
			a(d.milliseconds, 4 * 60 * 60 * 1000 + 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 4 * 60 * 60 + 7 * 60 + 12, "Seconds");
			a(d.minutes, 4 * 60 + 7, "Minutes");
			a(d.hours, 4, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
github medikoo / duration / test / index.js View on Github external
"Seconds": function (a) {
			// 7 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 7);

			d = t(d1, d2);
			a(d.milliseconds, 7 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 7, "Seconds");
			a(d.minutes, 0, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
			a(d.second, 7, "Trailing seconds");
			a(d.minute, 0, "Trailing minutes");
github medikoo / duration / test / index.js View on Github external
"Milliseconds": function (a) {
			// 11 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 11);

			d = t(d1, d2);
			a(d.milliseconds, 11, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 0, "Seconds");
			a(d.minutes, 0, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 11, "Trailing milliseconds");
			a(d.second, 0, "Trailing seconds");
			a(d.minute, 0, "Trailing minutes");
			a(d.hour, 0, "Trailing hours");
github medikoo / duration / test / index.js View on Github external
"Minutes": function (a) {
			// 7 minutes 12 seconds 123 milliseconds
			d2 = copy.call(d1);
			d2.setMilliseconds(d2.getMilliseconds() + 123);
			d2.setSeconds(d2.getSeconds() + 12);
			d2.setMinutes(d2.getMinutes() + 7);

			d = t(d1, d2);
			a(d.milliseconds, 7 * 60 * 1000 + 12 * 1000 + 123, "Milliseconds");
			a(d.valueOf(), d.milliseconds, "Value");
			a(d.seconds, 7 * 60 + 12, "Seconds");
			a(d.minutes, 7, "Minutes");
			a(d.hours, 0, "Hours");
			a(d.days, 0, "Days");
			a(d.months, 0, "Months");
			a(d.years, 0, "Years");

			a(d.millisecond, 123, "Trailing milliseconds");
			a(d.second, 12, "Trailing seconds");
github medikoo / duration / index.js View on Github external
day: d.gs(function () {
		var data = getCalcData(this);
		var toDays = data.to.getDate(), fromDays = data.from.getDate();
		var isToLater =
			data.to - dfloor.call(copy.call(data.to)) >=
			data.from - dfloor.call(copy.call(data.from));
		var result;
		if (toDays > fromDays) {
			result = toDays - fromDays;
			if (!isToLater) --result;
			return data.sign * result;
		}
		if (toDays === fromDays && isToLater) {
			return 0;
		}
		result = isToLater ? toDays : toDays - 1;
		result += daysInMonth.call(data.from) - data.from.getDate();
		return data.sign * result;
	}),
	month: d.gs(function () {
github medikoo / duration / index.js View on Github external
(getYear = function () {
			var data = getCalcData(this);
			return (
				data.sign *
				(data.to.getFullYear() -
					data.from.getFullYear() -
					(data.from - yfloor.call(copy.call(data.from)) >
						data.to - yfloor.call(copy.call(data.to))))
			);
		})
	),
github medikoo / date-from-timezone / index.js View on Github external
hours = 0,
		minutes = 0,
		seconds = 0,
		milliseconds = 0
	) {
		yearOrTimeValue = ensureNumber(yearOrTimeValue);
		let sampleDate;
		if (isValue(month)) {
			month = ensureNumber(month);
			sampleDate = new Date(
				yearOrTimeValue, month, date, hours, minutes, seconds, milliseconds
			);
		} else {
			sampleDate = new Date(yearOrTimeValue);
		}
		return resolveDate(sampleDate, copyDate.call(sampleDate), tokenize);
	};
};
github medikoo / duration / index.js View on Github external
(getYear = function () {
			var data = getCalcData(this);
			return (
				data.sign *
				(data.to.getFullYear() -
					data.from.getFullYear() -
					(data.from - yfloor.call(copy.call(data.from)) >
						data.to - yfloor.call(copy.call(data.to))))
			);
		})
	),
github medikoo / duration / index.js View on Github external
months: d.gs(function () {
		var data = getCalcData(this);
		return (
			data.sign *
			((data.to.getFullYear() - data.from.getFullYear()) * 12 +
				data.to.getMonth() -
				data.from.getMonth() -
				(data.from - mfloor.call(copy.call(data.from)) >
					data.to - mfloor.call(copy.call(data.to))))
		);
	}),
	years: d.gs(getYear),
github medikoo / dbjs / _setup / 4.type / 5.date-time.js View on Github external
}
			maxv = (descriptor && isNumber(descriptor.max))
				? min(descriptor.max, this.max)
				: this.max;
			if (value > maxv) {
				throw new DbjsError("Date cannot be after " + maxv, 'FUTURE_DATE',
					{ descriptor: descriptor });
			}
			step = (descriptor && isNumber(descriptor.step))
				? max(descriptor.step, this.step)
				: this.step;
			if (!step) return setPrototypeOf(value, this.prototype);
			trail = value % step;
			if (!trail) return setPrototypeOf(value, this.prototype);
			sign = (value >= 0) ? 1 : -1;
			if (!copied) value = copy.call(value);
			value.setTime(sign * floor(abs(value) * (1 / step)) * step);
			return setPrototypeOf(value, this.prototype);
		}),
		compare: d(function (a, b) { return a - b; }),