Brought in another asset for Ray's eye form: moment
[openemr.git] / public / assets / moment-2-13-0 / src / lib / units / millisecond.js
blob134d88ee92b269f37c8b04cc5695bf7f0f587f50
1 import { makeGetSet } from '../moment/get-set';
2 import { addFormatToken } from '../format/format';
3 import { addUnitAlias } from './aliases';
4 import { addRegexToken, match1, match2, match3, match1to3, matchUnsigned } from '../parse/regex';
5 import { addParseToken } from '../parse/token';
6 import { MILLISECOND } from './constants';
7 import toInt from '../utils/to-int';
9 // FORMATTING
11 addFormatToken('S', 0, 0, function () {
12     return ~~(this.millisecond() / 100);
13 });
15 addFormatToken(0, ['SS', 2], 0, function () {
16     return ~~(this.millisecond() / 10);
17 });
19 addFormatToken(0, ['SSS', 3], 0, 'millisecond');
20 addFormatToken(0, ['SSSS', 4], 0, function () {
21     return this.millisecond() * 10;
22 });
23 addFormatToken(0, ['SSSSS', 5], 0, function () {
24     return this.millisecond() * 100;
25 });
26 addFormatToken(0, ['SSSSSS', 6], 0, function () {
27     return this.millisecond() * 1000;
28 });
29 addFormatToken(0, ['SSSSSSS', 7], 0, function () {
30     return this.millisecond() * 10000;
31 });
32 addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
33     return this.millisecond() * 100000;
34 });
35 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
36     return this.millisecond() * 1000000;
37 });
40 // ALIASES
42 addUnitAlias('millisecond', 'ms');
44 // PARSING
46 addRegexToken('S',    match1to3, match1);
47 addRegexToken('SS',   match1to3, match2);
48 addRegexToken('SSS',  match1to3, match3);
50 var token;
51 for (token = 'SSSS'; token.length <= 9; token += 'S') {
52     addRegexToken(token, matchUnsigned);
55 function parseMs(input, array) {
56     array[MILLISECOND] = toInt(('0.' + input) * 1000);
59 for (token = 'S'; token.length <= 9; token += 'S') {
60     addParseToken(token, parseMs);
62 // MOMENTS
64 export var getSetMillisecond = makeGetSet('Milliseconds', false);