src/scales/scale.realtime.js
function toTimestamp(scale, input) {
	var adapter = scale._adapter || defaultAdapter;
	var options = scale.options.time;
	var parser = options.parser;
	var format = parser || options.format;
	var value = input;

	if (typeof parser === 'function') {
		value = parser(value);
	}

	// Only parse if its not a timestamp already
	if (typeof value !== 'number' && !(value instanceof Number) || !isFinite(value)) {
		value = typeof format === 'string'
			? adapter.parse(value, format)
			: adapter.parse(value);
	}

	if (value !== null) {
		return +value;
	}

	// Labels are in an incompatible format and no `parser` has been provided.
	// The user might still use the deprecated `format` option for parsing.
	if (!parser && typeof format === 'function') {
		value = format(input);

		// `format` could return something else than a timestamp, if so, parse it
		if (typeof value !== 'number' && !(value instanceof Number) || !isFinite(value)) {
			value = adapter.parse(value);
		}
	}

	return value;
}
function toTimestamp(scale, input) {
	var adapter = scale._adapter || defaultAdapter;
	var options = scale.options.time;
	var parser = options.parser;
	var format = parser || options.format;
	var value = input;

	if (typeof parser === 'function') {
		value = parser(value);
	}

	// Only parse if its not a timestamp already
	if (typeof value !== 'number' && !(value instanceof Number) || !isFinite(value)) {
		value = typeof format === 'string'
			? adapter.parse(value, format)
			: adapter.parse(value);
	}

	if (value !== null) {
		return +value;
	}

	// Labels are in an incompatible format and no `parser` has been provided.
	// The user might still use the deprecated `format` option for parsing.
	if (!parser && typeof format === 'function') {
		value = format(input);

		// `format` could return something else than a timestamp, if so, parse it
		if (typeof value !== 'number' && !(value instanceof Number) || !isFinite(value)) {
			value = adapter.parse(value);
		}
	}

	return value;
}
function toTimestamp ( scale , input ) { var adapter = scale . _adapter || defaultAdapter ; var options = scale . options . time ; var parser = options . parser ; var format = parser || options . format ; var value = input ; if ( typeof parser === 'function' ) { value = parser ( value ) ; } // Only parse if its not a timestamp already if ( typeof value !== 'number' && ! ( value instanceof Number ) || ! isFinite ( value ) ) { value = typeof format === 'string' ? adapter . parse ( value , format ) : adapter . parse ( value ) ; } if ( value !== null ) { return + value ; } // Labels are in an incompatible format and no `parser` has been provided. // The user might still use the deprecated `format` option for parsing. if ( ! parser && typeof format === 'function' ) { value = format ( input ) ; // `format` could return something else than a timestamp, if so, parse it if ( typeof value !== 'number' && ! ( value instanceof Number ) || ! isFinite ( value ) ) { value = adapter . parse ( value ) ; } } return value ; }
Ported from Chart.js 2.8.0-rc.1 35273ee. Modified for Chart.js 2.7.x backward compatibility.
Ported from Chart . js 2 . 8 . 0 - rc . 1 35273ee . Modified for Chart . js 2 . 7 . x backward compatibility .