corrade-nucleus-nucleons – Blame information for rev 14
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
10 | office | 1 | import zeroFill from '../utils/zero-fill'; |
2 | import isFunction from '../utils/is-function'; |
||
3 | |||
4 | export var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g; |
||
5 | |||
6 | var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; |
||
7 | |||
8 | var formatFunctions = {}; |
||
9 | |||
10 | export var formatTokenFunctions = {}; |
||
11 | |||
12 | // token: 'M' |
||
13 | // padded: ['MM', 2] |
||
14 | // ordinal: 'Mo' |
||
15 | // callback: function () { this.month() + 1 } |
||
16 | export function addFormatToken (token, padded, ordinal, callback) { |
||
17 | var func = callback; |
||
18 | if (typeof callback === 'string') { |
||
19 | func = function () { |
||
20 | return this[callback](); |
||
21 | }; |
||
22 | } |
||
23 | if (token) { |
||
24 | formatTokenFunctions[token] = func; |
||
25 | } |
||
26 | if (padded) { |
||
27 | formatTokenFunctions[padded[0]] = function () { |
||
28 | return zeroFill(func.apply(this, arguments), padded[1], padded[2]); |
||
29 | }; |
||
30 | } |
||
31 | if (ordinal) { |
||
32 | formatTokenFunctions[ordinal] = function () { |
||
33 | return this.localeData().ordinal(func.apply(this, arguments), token); |
||
34 | }; |
||
35 | } |
||
36 | } |
||
37 | |||
38 | function removeFormattingTokens(input) { |
||
39 | if (input.match(/\[[\s\S]/)) { |
||
40 | return input.replace(/^\[|\]$/g, ''); |
||
41 | } |
||
42 | return input.replace(/\\/g, ''); |
||
43 | } |
||
44 | |||
45 | function makeFormatFunction(format) { |
||
46 | var array = format.match(formattingTokens), i, length; |
||
47 | |||
48 | for (i = 0, length = array.length; i < length; i++) {> |
||
49 | < length; i++) { if (formatTokenFunctions[array[i]]) {> |
||
50 | < length; i++) { array[i] = formatTokenFunctions[array[i]];> |
||
51 | < length; i++) { } else {> |
||
52 | < length; i++) { array[i] = removeFormattingTokens(array[i]);> |
||
53 | < length; i++) { }> |
||
54 | < length; i++) { }> |
||
55 | |||
56 | < length; i++) { return function (mom) {> |
||
57 | < length; i++) { var output = '', i;> |
||
58 | < length; i++) { for (i = 0; i < length; i++) {>> |
||
59 | < length; i++) {< length; i++) { output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];>> |
||
60 | < length; i++) {< length; i++) { }>> |
||
61 | < length; i++) {< length; i++) { return output;>> |
||
62 | < length; i++) {< length; i++) { };>> |
||
63 | < length; i++) {< length; i++) {}>> |
||
64 | |||
65 | < length; i++) {< length; i++) {// format date using native date object>> |
||
66 | < length; i++) {< length; i++) {export function formatMoment(m, format) {>> |
||
67 | < length; i++) {< length; i++) { if (!m.isValid()) {>> |
||
68 | < length; i++) {< length; i++) { return m.localeData().invalidDate();>> |
||
69 | < length; i++) {< length; i++) { }>> |
||
70 | |||
71 | < length; i++) {< length; i++) { format = expandFormat(format, m.localeData());>> |
||
72 | < length; i++) {< length; i++) { formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);>> |
||
73 | |||
74 | < length; i++) {< length; i++) { return formatFunctions[format](m);>> |
||
75 | < length; i++) {< length; i++) {}>> |
||
76 | |||
77 | < length; i++) {< length; i++) {export function expandFormat(format, locale) {>> |
||
78 | < length; i++) {< length; i++) { var i = 5;>> |
||
79 | |||
80 | < length; i++) {< length; i++) { function replaceLongDateFormatTokens(input) {>> |
||
81 | < length; i++) {< length; i++) { return locale.longDateFormat(input) || input;>> |
||
82 | < length; i++) {< length; i++) { }>> |
||
83 | |||
84 | < length; i++) {< length; i++) { localFormattingTokens.lastIndex = 0;>> |
||
85 | < length; i++) {< length; i++) { while (i >= 0 && localFormattingTokens.test(format)) {>> |
||
86 | < length; i++) {< length; i++) { format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);>> |
||
87 | < length; i++) {< length; i++) { localFormattingTokens.lastIndex = 0;>> |
||
88 | < length; i++) {< length; i++) { i -= 1;>> |
||
89 | < length; i++) {< length; i++) { }>> |
||
90 | |||
91 | < length; i++) {< length; i++) { return format;>> |
||
92 | < length; i++) {< length; i++) {}>> |