src/time/dates.js
function adjust(r, e, time, def) {
	const requested = r[def.field];
	const current = def.get(time, e.options);

	if(r.relationToCurrent === 'auto') {
		if(requested < current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'current-period') {
		if(def.parentData(r) && requested < current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'future') {
		if(requested <= current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'past') {
		if(requested >= current) {
			time = def.set(def.adjuster(time, -1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	}

	return time;
}
function adjust(r, e, time, def) {
	const requested = r[def.field];
	const current = def.get(time, e.options);

	if(r.relationToCurrent === 'auto') {
		if(requested < current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'current-period') {
		if(def.parentData(r) && requested < current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'future') {
		if(requested <= current) {
			time = def.set(def.adjuster(time, 1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	} else if(r.relationToCurrent === 'past') {
		if(requested >= current) {
			time = def.set(def.adjuster(time, -1, e.options), requested, e.options);
		} else {
			time = def.set(time, requested, e.options);
		}
	}

	return time;
}
function adjust ( r , e , time , def ) { const requested = r [ def . field ] ; const current = def . get ( time , e . options ) ; if ( r . relationToCurrent === 'auto' ) { if ( requested < current ) { time = def . set ( def . adjuster ( time , 1 , e . options ) , requested , e . options ) ; } else { time = def . set ( time , requested , e . options ) ; } } else if ( r . relationToCurrent === 'current-period' ) { if ( def . parentData ( r ) && requested < current ) { time = def . set ( def . adjuster ( time , 1 , e . options ) , requested , e . options ) ; } else { time = def . set ( time , requested , e . options ) ; } } else if ( r . relationToCurrent === 'future' ) { if ( requested <= current ) { time = def . set ( def . adjuster ( time , 1 , e . options ) , requested , e . options ) ; } else { time = def . set ( time , requested , e . options ) ; } } else if ( r . relationToCurrent === 'past' ) { if ( requested >= current ) { time = def . set ( def . adjuster ( time , - 1 , e . options ) , requested , e . options ) ; } else { time = def . set ( time , requested , e . options ) ; } } return time ; }
Adjust the current time based on a field. Implements different strategies
such as automatic, which tries to adjust the field forward if it's in the
past.

@param {Date} time
the current time
@param {Object} r
the object containing the data
@param {*} def
definition describing the field to modify
Adjust the current time based on a field . Implements different strategies such as automatic which tries to adjust the field forward if it s in the past .