corrade-nucleus-nucleons – Blame information for rev 10
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
10 | office | 1 | import { makeGetSet } from '../moment/get-set'; |
2 | import { addFormatToken } from '../format/format'; |
||
3 | import { addUnitAlias } from './aliases'; |
||
4 | import { addUnitPriority } from './priorities'; |
||
5 | import { addRegexToken, match1, match2, match3, match1to3, matchUnsigned } from '../parse/regex'; |
||
6 | import { addParseToken } from '../parse/token'; |
||
7 | import { MILLISECOND } from './constants'; |
||
8 | import toInt from '../utils/to-int'; |
||
9 | |||
10 | // FORMATTING |
||
11 | |||
12 | addFormatToken('S', 0, 0, function () { |
||
13 | return ~~(this.millisecond() / 100); |
||
14 | }); |
||
15 | |||
16 | addFormatToken(0, ['SS', 2], 0, function () { |
||
17 | return ~~(this.millisecond() / 10); |
||
18 | }); |
||
19 | |||
20 | addFormatToken(0, ['SSS', 3], 0, 'millisecond'); |
||
21 | addFormatToken(0, ['SSSS', 4], 0, function () { |
||
22 | return this.millisecond() * 10; |
||
23 | }); |
||
24 | addFormatToken(0, ['SSSSS', 5], 0, function () { |
||
25 | return this.millisecond() * 100; |
||
26 | }); |
||
27 | addFormatToken(0, ['SSSSSS', 6], 0, function () { |
||
28 | return this.millisecond() * 1000; |
||
29 | }); |
||
30 | addFormatToken(0, ['SSSSSSS', 7], 0, function () { |
||
31 | return this.millisecond() * 10000; |
||
32 | }); |
||
33 | addFormatToken(0, ['SSSSSSSS', 8], 0, function () { |
||
34 | return this.millisecond() * 100000; |
||
35 | }); |
||
36 | addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { |
||
37 | return this.millisecond() * 1000000; |
||
38 | }); |
||
39 | |||
40 | |||
41 | // ALIASES |
||
42 | |||
43 | addUnitAlias('millisecond', 'ms'); |
||
44 | |||
45 | // PRIORITY |
||
46 | |||
47 | addUnitPriority('millisecond', 16); |
||
48 | |||
49 | // PARSING |
||
50 | |||
51 | addRegexToken('S', match1to3, match1); |
||
52 | addRegexToken('SS', match1to3, match2); |
||
53 | addRegexToken('SSS', match1to3, match3); |
||
54 | |||
55 | var token; |
||
56 | for (token = 'SSSS'; token.length <= 9; token += 'S') { |
||
57 | addRegexToken(token, matchUnsigned); |
||
58 | } |
||
59 | |||
60 | function parseMs(input, array) { |
||
61 | array[MILLISECOND] = toInt(('0.' + input) * 1000); |
||
62 | } |
||
63 | |||
64 | for (token = 'S'; token.length <= 9; token += 'S') { |
||
65 | addParseToken(token, parseMs); |
||
66 | } |
||
67 | // MOMENTS |
||
68 | |||
69 | export var getSetMillisecond = makeGetSet('Milliseconds', false); |