How to use the jsprim.iso8601 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 / test / tst.promote_primary.js View on Github external
{ 'cmd': 'echo', 'args': [ 'test: ignore (promotePrimary)' ] },
    { 'cmd': 'promote', 'args': [ {
	'id': 'node1',
	'role': 'primary',
	'generation': 2,
	'expireIn': 200
    } ] },
    { 'cmd': 'zk', 'check': ignoredState, 'wait': 300 },

    { 'cmd': 'echo', 'args': [ 'test: ignore (expireTimePassed)' ] },
    { 'cmd': 'promote', 'args': [ {
	'id': 'node5',
	'role': 'async',
	'asyncIndex': 2,
	'generation': 2,
	'expireTime': mod_jsprim.iso8601(new Date('2010-01-01T00:00:00.000Z'))
    } ] },
    { 'cmd': 'zk', 'check': ignoredState, 'wait': 300 },

    { 'cmd': 'echo', 'args': [ 'test: ignore (invalidIdAtRole)' ] },
    { 'cmd': 'promote', 'args': [ {
	'id': 'node4',
	'role': 'sync',
	'generation': 2,
	'expireIn': 200
    } ] },
    { 'cmd': 'zk', 'check': ignoredState, 'wait': 300 },

    { 'cmd': 'echo', 'args': [ 'test: ignore (invalidIdAtAsyncIndex)' ] },
    { 'cmd': 'promote', 'args': [ {
	'id': 'node2',
	'role': 'async',
github joyent / manatee / lib / adm.js View on Github external
function buildPromoteState(_, cb) {
            _.promote = {};
            if (_.role === 'sync') {
                _.promote.id = _.state[_.shard][_.role].id;
            } else {
                _.promote.id = _.state[_.shard].async[_.asyncIndex].id;
                _.promote.asyncIndex = _.asyncIndex;
            }
            _.promote.role = _.role;
            _.promote.generation = _.state[_.shard].generation;
            _.promote.expireTime =
                jsprim.iso8601(new Date().getTime() + (30 * 1000));

            cb();
        },
        function setPromoteState(_, cb) {
github joyent / manatee-state-machine / lib / sim.js View on Github external
Simulator.prototype.cmdPromote = function (promote)
{
	var t, zkstate;

	mod_assertplus.object(promote, 'promote');
	mod_assertplus.optionalNumber(promote.expireIn, 'promote.expireIn');

	if (promote.expireIn) {
		t = new Date().getTime() + promote.expireIn;
		promote.expireTime = mod_jsprim.iso8601(new Date(t));
		delete (promote.expireIn);
	}

	zkstate = this.ms_zk.currentClusterState();
	zkstate.promote = promote;

	this.ms_zk.setClusterState(zkstate);

	return (this.simpleZkState(this.ms_zk.currentClusterState()));
};