Sha256: a3ff5dd3b50ad930fd1d294e09c3286595f6113108c59b540a01cb3b1b166e6d

Contents?: true

Size: 1.83 KB

Versions: 19

Compression:

Stored size: 1.83 KB

Contents

import { makeGetSet } from '../moment/get-set';
import { addFormatToken } from '../format/format';
import { addUnitAlias } from './aliases';
import { addUnitPriority } from './priorities';
import {
    addRegexToken,
    match1,
    match2,
    match3,
    match1to3,
    matchUnsigned,
} from '../parse/regex';
import { addParseToken } from '../parse/token';
import { MILLISECOND } from './constants';
import toInt from '../utils/to-int';

// FORMATTING

addFormatToken('S', 0, 0, function () {
    return ~~(this.millisecond() / 100);
});

addFormatToken(0, ['SS', 2], 0, function () {
    return ~~(this.millisecond() / 10);
});

addFormatToken(0, ['SSS', 3], 0, 'millisecond');
addFormatToken(0, ['SSSS', 4], 0, function () {
    return this.millisecond() * 10;
});
addFormatToken(0, ['SSSSS', 5], 0, function () {
    return this.millisecond() * 100;
});
addFormatToken(0, ['SSSSSS', 6], 0, function () {
    return this.millisecond() * 1000;
});
addFormatToken(0, ['SSSSSSS', 7], 0, function () {
    return this.millisecond() * 10000;
});
addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
    return this.millisecond() * 100000;
});
addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
    return this.millisecond() * 1000000;
});

// ALIASES

addUnitAlias('millisecond', 'ms');

// PRIORITY

addUnitPriority('millisecond', 16);

// PARSING

addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);

var token, getSetMillisecond;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
    addRegexToken(token, matchUnsigned);
}

function parseMs(input, array) {
    array[MILLISECOND] = toInt(('0.' + input) * 1000);
}

for (token = 'S'; token.length <= 9; token += 'S') {
    addParseToken(token, parseMs);
}

getSetMillisecond = makeGetSet('Milliseconds', false);

export { getSetMillisecond };

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-mod-date-0.15.6 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.15.0 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.14.2 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.14.1 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.14.0 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.13.4 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.13.3 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.13.2 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.13.1 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.13.0 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.7 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.12.0 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.6 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.5 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.4 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.3 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.2 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.1 vendor/moment/src/lib/units/millisecond.js
card-mod-date-0.11.0 vendor/moment/src/lib/units/millisecond.js