How to use the jsprim.parseDateTime function in jsprim

To help you get started, we’ve selected a few jsprim 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 joyent / manatee-state-machine / lib / validation.js View on Github external
function validatePromoteRequest(clusterState)
{
	var promote, error, expireTime;
	promote = mod_jsprim.pluck(clusterState, 'promote');

	if (!promote)
		return (undefined);

	error = validateAndCopy(schemas.promote, promote);
	if (error instanceof Error)
		return (error);

	expireTime = mod_jsprim.parseDateTime(promote.expireTime);
	if (isNaN(expireTime.getTime())) {
		return (new VError('expireTime is not parseable (found "%s")',
		    promote.expireTime));
	}

	if (promote.generation !== clusterState.generation) {
		return (new VError('generation does not match (expected %d, ' +
		    'found %d)', clusterState.generation, promote.generation));
	}

	if (expireTime.getTime() < new Date().getTime())
		return (new VError('expireTime has passed ("%s")',
		    promote.expireTime));

	if (promote.role === 'async') {
		if (!promote.hasOwnProperty('asyncIndex')) {