kea-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kea-rails/version.rb +1 -1
- data/vendor/assets/components/Keypress/LICENSE +191 -0
- data/vendor/assets/components/Keypress/README.md +78 -0
- data/vendor/assets/components/Keypress/bower.json +28 -0
- data/vendor/assets/components/Keypress/keypress-2.1.0.min.js +33 -0
- data/vendor/assets/components/Keypress/keypress.coffee +921 -0
- data/vendor/assets/components/Keypress/keypress.js +1132 -0
- data/vendor/assets/components/Keypress/package.json +15 -0
- data/vendor/assets/components/attachejs/attache-jquery.js +47 -0
- data/vendor/assets/components/attachejs/attache-knockout.js +56 -0
- data/vendor/assets/components/attachejs/attache.css +10 -0
- data/vendor/assets/components/attachejs/attache.js +589 -0
- data/vendor/assets/components/attachejs/bower.json +36 -0
- data/vendor/assets/components/humane-js/bower.json +8 -0
- data/vendor/assets/components/humane-js/changelog.md +165 -0
- data/vendor/assets/components/humane-js/humane.js +238 -0
- data/vendor/assets/components/humane-js/humane.min.js +11 -0
- data/vendor/assets/components/humane-js/index.html +190 -0
- data/vendor/assets/components/humane-js/package.json +25 -0
- data/vendor/assets/components/humane-js/readme.md +85 -0
- data/vendor/assets/components/humane-js/test/issue23.html +11 -0
- data/vendor/assets/components/humane-js/test/issue36.html +9 -0
- data/vendor/assets/components/humane-js/test/issue38.html +15 -0
- data/vendor/assets/components/humane-js/test/issue49.html +9 -0
- data/vendor/assets/components/humane-js/theme-src/bigbox.styl +65 -0
- data/vendor/assets/components/humane-js/theme-src/boldlight.styl +64 -0
- data/vendor/assets/components/humane-js/theme-src/jackedup.styl +69 -0
- data/vendor/assets/components/humane-js/theme-src/libnotify.styl +61 -0
- data/vendor/assets/components/humane-js/theme-src/original.styl +51 -0
- data/vendor/assets/components/humane-js/themes/bigbox.css +123 -0
- data/vendor/assets/components/humane-js/themes/boldlight.css +122 -0
- data/vendor/assets/components/humane-js/themes/flatty.css +94 -0
- data/vendor/assets/components/humane-js/themes/jackedup.css +123 -0
- data/vendor/assets/components/humane-js/themes/libnotify.css +115 -0
- data/vendor/assets/components/humane-js/themes/original.css +72 -0
- data/vendor/assets/components/knockout-sortable/README.md +129 -0
- data/vendor/assets/components/knockout-sortable/bower.json +15 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.js +358 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.min.js +2 -0
- data/vendor/assets/components/uri.js/README.md +437 -0
- data/vendor/assets/components/uri.js/URI.jquery.json +38 -0
- data/vendor/assets/components/uri.js/about-uris.html +156 -0
- data/vendor/assets/components/uri.js/build.html +66 -0
- data/vendor/assets/components/uri.js/build.js +78 -0
- data/vendor/assets/components/uri.js/component.json +15 -0
- data/vendor/assets/components/uri.js/contribute.md +11 -0
- data/vendor/assets/components/uri.js/docs.html +1280 -0
- data/vendor/assets/components/uri.js/index.html +173 -0
- data/vendor/assets/components/uri.js/jquery-1.10.2.min.js +6 -0
- data/vendor/assets/components/uri.js/jquery-1.7.2.min.js +4 -0
- data/vendor/assets/components/uri.js/jquery-1.8.2.min.js +2 -0
- data/vendor/assets/components/uri.js/jquery-1.9.1.min.js +5 -0
- data/vendor/assets/components/uri.js/jquery-uri-plugin.html +203 -0
- data/vendor/assets/components/uri.js/package.json +75 -0
- data/vendor/assets/components/uri.js/prettify/lang-apollo.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-clj.js +18 -0
- data/vendor/assets/components/uri.js/prettify/lang-css.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-go.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-hs.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-lisp.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-lua.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-ml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-n.js +4 -0
- data/vendor/assets/components/uri.js/prettify/lang-proto.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-scala.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-sql.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-tex.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-vb.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-vhdl.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-wiki.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-xq.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-yaml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/prettify.css +1 -0
- data/vendor/assets/components/uri.js/prettify/prettify.js +28 -0
- data/vendor/assets/components/uri.js/prettify/prettify.sunburst.css +52 -0
- data/vendor/assets/components/uri.js/screen.css +167 -0
- data/vendor/assets/components/uri.js/screen.js +39 -0
- data/vendor/assets/components/uri.js/src/IPv6.js +185 -0
- data/vendor/assets/components/uri.js/src/SecondLevelDomains.js +220 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentQuery.js +103 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentURI.js +96 -0
- data/vendor/assets/components/uri.js/src/URI.js +1938 -0
- data/vendor/assets/components/uri.js/src/URI.min.js +81 -0
- data/vendor/assets/components/uri.js/src/URITemplate.js +494 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.js +232 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.min.js +7 -0
- data/vendor/assets/components/uri.js/src/punycode.js +508 -0
- data/vendor/assets/components/uri.js/test/index.html +26 -0
- data/vendor/assets/components/uri.js/test/pre_libs.js +4 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.css +13 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.js +167 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.css +244 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.js +2212 -0
- data/vendor/assets/components/uri.js/test/test.URI.html +26 -0
- data/vendor/assets/components/uri.js/test/test.fragmentQuery.html +31 -0
- data/vendor/assets/components/uri.js/test/test.fragmentURI.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.10.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.7.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.8.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.9.html +31 -0
- data/vendor/assets/components/uri.js/test/test.js +1409 -0
- data/vendor/assets/components/uri.js/test/test_fragmentQuery.js +57 -0
- data/vendor/assets/components/uri.js/test/test_fragmentURI.js +59 -0
- data/vendor/assets/components/uri.js/test/test_jim.js +143 -0
- data/vendor/assets/components/uri.js/test/test_jquery.js +138 -0
- data/vendor/assets/components/uri.js/test/test_template.js +385 -0
- data/vendor/assets/components/uri.js/test/urls.js +1236 -0
- data/vendor/assets/components/uri.js/uri-template.html +234 -0
- data/vendor/assets/components/uri.js/utils/SLDs.php +37 -0
- data/vendor/assets/components/uri.js/utils/sld.js +101 -0
- data/vendor/assets/components/veiljs/bower.json +36 -0
- data/vendor/assets/components/veiljs/veil-jquery.js +47 -0
- data/vendor/assets/components/veiljs/veil-knockout.js +55 -0
- data/vendor/assets/components/veiljs/veil.js +465 -0
- data/vendor/assets/javascripts/fuse.js +472 -0
- data/vendor/assets/javascripts/jquery-ui.js +3844 -0
- data/vendor/assets/javascripts/knockout-3.2.0-debug.js +5299 -0
- data/vendor/assets/javascripts/moment.js +1902 -0
- data/vendor/assets/javascripts/pikaday.js +896 -0
- data/vendor/assets/stylesheets/pikaday.css +171 -0
- metadata +120 -1
@@ -0,0 +1,1902 @@
|
|
1
|
+
//! moment.js
|
2
|
+
//! version : 2.2.1
|
3
|
+
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
4
|
+
//! license : MIT
|
5
|
+
//! momentjs.com
|
6
|
+
|
7
|
+
(function (undefined) {
|
8
|
+
|
9
|
+
/************************************
|
10
|
+
Constants
|
11
|
+
************************************/
|
12
|
+
|
13
|
+
var moment,
|
14
|
+
VERSION = "2.2.1",
|
15
|
+
round = Math.round, i,
|
16
|
+
// internal storage for language config files
|
17
|
+
languages = {},
|
18
|
+
|
19
|
+
// check for nodeJS
|
20
|
+
hasModule = (typeof module !== 'undefined' && module.exports),
|
21
|
+
|
22
|
+
// ASP.NET json date format regex
|
23
|
+
aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
|
24
|
+
aspNetTimeSpanJsonRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)\:(\d+)\.?(\d{3})?/,
|
25
|
+
|
26
|
+
// format tokens
|
27
|
+
formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,
|
28
|
+
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
|
29
|
+
|
30
|
+
// parsing token regexes
|
31
|
+
parseTokenOneOrTwoDigits = /\d\d?/, // 0 - 99
|
32
|
+
parseTokenOneToThreeDigits = /\d{1,3}/, // 0 - 999
|
33
|
+
parseTokenThreeDigits = /\d{3}/, // 000 - 999
|
34
|
+
parseTokenFourDigits = /\d{1,4}/, // 0 - 9999
|
35
|
+
parseTokenSixDigits = /[+\-]?\d{1,6}/, // -999,999 - 999,999
|
36
|
+
parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, // any word (or two) characters or numbers including two/three word month in arabic.
|
37
|
+
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, // +00:00 -00:00 +0000 -0000 or Z
|
38
|
+
parseTokenT = /T/i, // T (ISO seperator)
|
39
|
+
parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
|
40
|
+
|
41
|
+
// preliminary iso regex
|
42
|
+
// 0000-00-00 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000
|
43
|
+
isoRegex = /^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,
|
44
|
+
isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',
|
45
|
+
|
46
|
+
// iso time formats and regexes
|
47
|
+
isoTimes = [
|
48
|
+
['HH:mm:ss.S', /(T| )\d\d:\d\d:\d\d\.\d{1,3}/],
|
49
|
+
['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
|
50
|
+
['HH:mm', /(T| )\d\d:\d\d/],
|
51
|
+
['HH', /(T| )\d\d/]
|
52
|
+
],
|
53
|
+
|
54
|
+
// timezone chunker "+10:00" > ["10", "00"] or "-1530" > ["-15", "30"]
|
55
|
+
parseTimezoneChunker = /([\+\-]|\d\d)/gi,
|
56
|
+
|
57
|
+
// getter and setter names
|
58
|
+
proxyGettersAndSetters = 'Date|Hours|Minutes|Seconds|Milliseconds'.split('|'),
|
59
|
+
unitMillisecondFactors = {
|
60
|
+
'Milliseconds' : 1,
|
61
|
+
'Seconds' : 1e3,
|
62
|
+
'Minutes' : 6e4,
|
63
|
+
'Hours' : 36e5,
|
64
|
+
'Days' : 864e5,
|
65
|
+
'Months' : 2592e6,
|
66
|
+
'Years' : 31536e6
|
67
|
+
},
|
68
|
+
|
69
|
+
unitAliases = {
|
70
|
+
ms : 'millisecond',
|
71
|
+
s : 'second',
|
72
|
+
m : 'minute',
|
73
|
+
h : 'hour',
|
74
|
+
d : 'day',
|
75
|
+
w : 'week',
|
76
|
+
W : 'isoweek',
|
77
|
+
M : 'month',
|
78
|
+
y : 'year'
|
79
|
+
},
|
80
|
+
|
81
|
+
// format function strings
|
82
|
+
formatFunctions = {},
|
83
|
+
|
84
|
+
// tokens to ordinalize and pad
|
85
|
+
ordinalizeTokens = 'DDD w W M D d'.split(' '),
|
86
|
+
paddedTokens = 'M D H h m s w W'.split(' '),
|
87
|
+
|
88
|
+
formatTokenFunctions = {
|
89
|
+
M : function () {
|
90
|
+
return this.month() + 1;
|
91
|
+
},
|
92
|
+
MMM : function (format) {
|
93
|
+
return this.lang().monthsShort(this, format);
|
94
|
+
},
|
95
|
+
MMMM : function (format) {
|
96
|
+
return this.lang().months(this, format);
|
97
|
+
},
|
98
|
+
D : function () {
|
99
|
+
return this.date();
|
100
|
+
},
|
101
|
+
DDD : function () {
|
102
|
+
return this.dayOfYear();
|
103
|
+
},
|
104
|
+
d : function () {
|
105
|
+
return this.day();
|
106
|
+
},
|
107
|
+
dd : function (format) {
|
108
|
+
return this.lang().weekdaysMin(this, format);
|
109
|
+
},
|
110
|
+
ddd : function (format) {
|
111
|
+
return this.lang().weekdaysShort(this, format);
|
112
|
+
},
|
113
|
+
dddd : function (format) {
|
114
|
+
return this.lang().weekdays(this, format);
|
115
|
+
},
|
116
|
+
w : function () {
|
117
|
+
return this.week();
|
118
|
+
},
|
119
|
+
W : function () {
|
120
|
+
return this.isoWeek();
|
121
|
+
},
|
122
|
+
YY : function () {
|
123
|
+
return leftZeroFill(this.year() % 100, 2);
|
124
|
+
},
|
125
|
+
YYYY : function () {
|
126
|
+
return leftZeroFill(this.year(), 4);
|
127
|
+
},
|
128
|
+
YYYYY : function () {
|
129
|
+
return leftZeroFill(this.year(), 5);
|
130
|
+
},
|
131
|
+
gg : function () {
|
132
|
+
return leftZeroFill(this.weekYear() % 100, 2);
|
133
|
+
},
|
134
|
+
gggg : function () {
|
135
|
+
return this.weekYear();
|
136
|
+
},
|
137
|
+
ggggg : function () {
|
138
|
+
return leftZeroFill(this.weekYear(), 5);
|
139
|
+
},
|
140
|
+
GG : function () {
|
141
|
+
return leftZeroFill(this.isoWeekYear() % 100, 2);
|
142
|
+
},
|
143
|
+
GGGG : function () {
|
144
|
+
return this.isoWeekYear();
|
145
|
+
},
|
146
|
+
GGGGG : function () {
|
147
|
+
return leftZeroFill(this.isoWeekYear(), 5);
|
148
|
+
},
|
149
|
+
e : function () {
|
150
|
+
return this.weekday();
|
151
|
+
},
|
152
|
+
E : function () {
|
153
|
+
return this.isoWeekday();
|
154
|
+
},
|
155
|
+
a : function () {
|
156
|
+
return this.lang().meridiem(this.hours(), this.minutes(), true);
|
157
|
+
},
|
158
|
+
A : function () {
|
159
|
+
return this.lang().meridiem(this.hours(), this.minutes(), false);
|
160
|
+
},
|
161
|
+
H : function () {
|
162
|
+
return this.hours();
|
163
|
+
},
|
164
|
+
h : function () {
|
165
|
+
return this.hours() % 12 || 12;
|
166
|
+
},
|
167
|
+
m : function () {
|
168
|
+
return this.minutes();
|
169
|
+
},
|
170
|
+
s : function () {
|
171
|
+
return this.seconds();
|
172
|
+
},
|
173
|
+
S : function () {
|
174
|
+
return ~~(this.milliseconds() / 100);
|
175
|
+
},
|
176
|
+
SS : function () {
|
177
|
+
return leftZeroFill(~~(this.milliseconds() / 10), 2);
|
178
|
+
},
|
179
|
+
SSS : function () {
|
180
|
+
return leftZeroFill(this.milliseconds(), 3);
|
181
|
+
},
|
182
|
+
Z : function () {
|
183
|
+
var a = -this.zone(),
|
184
|
+
b = "+";
|
185
|
+
if (a < 0) {
|
186
|
+
a = -a;
|
187
|
+
b = "-";
|
188
|
+
}
|
189
|
+
return b + leftZeroFill(~~(a / 60), 2) + ":" + leftZeroFill(~~a % 60, 2);
|
190
|
+
},
|
191
|
+
ZZ : function () {
|
192
|
+
var a = -this.zone(),
|
193
|
+
b = "+";
|
194
|
+
if (a < 0) {
|
195
|
+
a = -a;
|
196
|
+
b = "-";
|
197
|
+
}
|
198
|
+
return b + leftZeroFill(~~(10 * a / 6), 4);
|
199
|
+
},
|
200
|
+
z : function () {
|
201
|
+
return this.zoneAbbr();
|
202
|
+
},
|
203
|
+
zz : function () {
|
204
|
+
return this.zoneName();
|
205
|
+
},
|
206
|
+
X : function () {
|
207
|
+
return this.unix();
|
208
|
+
}
|
209
|
+
};
|
210
|
+
|
211
|
+
function padToken(func, count) {
|
212
|
+
return function (a) {
|
213
|
+
return leftZeroFill(func.call(this, a), count);
|
214
|
+
};
|
215
|
+
}
|
216
|
+
function ordinalizeToken(func, period) {
|
217
|
+
return function (a) {
|
218
|
+
return this.lang().ordinal(func.call(this, a), period);
|
219
|
+
};
|
220
|
+
}
|
221
|
+
|
222
|
+
while (ordinalizeTokens.length) {
|
223
|
+
i = ordinalizeTokens.pop();
|
224
|
+
formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
|
225
|
+
}
|
226
|
+
while (paddedTokens.length) {
|
227
|
+
i = paddedTokens.pop();
|
228
|
+
formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
|
229
|
+
}
|
230
|
+
formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
|
231
|
+
|
232
|
+
|
233
|
+
/************************************
|
234
|
+
Constructors
|
235
|
+
************************************/
|
236
|
+
|
237
|
+
function Language() {
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
// Moment prototype object
|
242
|
+
function Moment(config) {
|
243
|
+
extend(this, config);
|
244
|
+
}
|
245
|
+
|
246
|
+
// Duration Constructor
|
247
|
+
function Duration(duration) {
|
248
|
+
var years = duration.years || duration.year || duration.y || 0,
|
249
|
+
months = duration.months || duration.month || duration.M || 0,
|
250
|
+
weeks = duration.weeks || duration.week || duration.w || 0,
|
251
|
+
days = duration.days || duration.day || duration.d || 0,
|
252
|
+
hours = duration.hours || duration.hour || duration.h || 0,
|
253
|
+
minutes = duration.minutes || duration.minute || duration.m || 0,
|
254
|
+
seconds = duration.seconds || duration.second || duration.s || 0,
|
255
|
+
milliseconds = duration.milliseconds || duration.millisecond || duration.ms || 0;
|
256
|
+
|
257
|
+
// store reference to input for deterministic cloning
|
258
|
+
this._input = duration;
|
259
|
+
|
260
|
+
// representation for dateAddRemove
|
261
|
+
this._milliseconds = +milliseconds +
|
262
|
+
seconds * 1e3 + // 1000
|
263
|
+
minutes * 6e4 + // 1000 * 60
|
264
|
+
hours * 36e5; // 1000 * 60 * 60
|
265
|
+
// Because of dateAddRemove treats 24 hours as different from a
|
266
|
+
// day when working around DST, we need to store them separately
|
267
|
+
this._days = +days +
|
268
|
+
weeks * 7;
|
269
|
+
// It is impossible translate months into days without knowing
|
270
|
+
// which months you are are talking about, so we have to store
|
271
|
+
// it separately.
|
272
|
+
this._months = +months +
|
273
|
+
years * 12;
|
274
|
+
|
275
|
+
this._data = {};
|
276
|
+
|
277
|
+
this._bubble();
|
278
|
+
}
|
279
|
+
|
280
|
+
|
281
|
+
/************************************
|
282
|
+
Helpers
|
283
|
+
************************************/
|
284
|
+
|
285
|
+
|
286
|
+
function extend(a, b) {
|
287
|
+
for (var i in b) {
|
288
|
+
if (b.hasOwnProperty(i)) {
|
289
|
+
a[i] = b[i];
|
290
|
+
}
|
291
|
+
}
|
292
|
+
return a;
|
293
|
+
}
|
294
|
+
|
295
|
+
function absRound(number) {
|
296
|
+
if (number < 0) {
|
297
|
+
return Math.ceil(number);
|
298
|
+
} else {
|
299
|
+
return Math.floor(number);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
// left zero fill a number
|
304
|
+
// see http://jsperf.com/left-zero-filling for performance comparison
|
305
|
+
function leftZeroFill(number, targetLength) {
|
306
|
+
var output = number + '';
|
307
|
+
while (output.length < targetLength) {
|
308
|
+
output = '0' + output;
|
309
|
+
}
|
310
|
+
return output;
|
311
|
+
}
|
312
|
+
|
313
|
+
// helper function for _.addTime and _.subtractTime
|
314
|
+
function addOrSubtractDurationFromMoment(mom, duration, isAdding, ignoreUpdateOffset) {
|
315
|
+
var milliseconds = duration._milliseconds,
|
316
|
+
days = duration._days,
|
317
|
+
months = duration._months,
|
318
|
+
minutes,
|
319
|
+
hours;
|
320
|
+
|
321
|
+
if (milliseconds) {
|
322
|
+
mom._d.setTime(+mom._d + milliseconds * isAdding);
|
323
|
+
}
|
324
|
+
// store the minutes and hours so we can restore them
|
325
|
+
if (days || months) {
|
326
|
+
minutes = mom.minute();
|
327
|
+
hours = mom.hour();
|
328
|
+
}
|
329
|
+
if (days) {
|
330
|
+
mom.date(mom.date() + days * isAdding);
|
331
|
+
}
|
332
|
+
if (months) {
|
333
|
+
mom.month(mom.month() + months * isAdding);
|
334
|
+
}
|
335
|
+
if (milliseconds && !ignoreUpdateOffset) {
|
336
|
+
moment.updateOffset(mom);
|
337
|
+
}
|
338
|
+
// restore the minutes and hours after possibly changing dst
|
339
|
+
if (days || months) {
|
340
|
+
mom.minute(minutes);
|
341
|
+
mom.hour(hours);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
// check if is an array
|
346
|
+
function isArray(input) {
|
347
|
+
return Object.prototype.toString.call(input) === '[object Array]';
|
348
|
+
}
|
349
|
+
|
350
|
+
// compare two arrays, return the number of differences
|
351
|
+
function compareArrays(array1, array2) {
|
352
|
+
var len = Math.min(array1.length, array2.length),
|
353
|
+
lengthDiff = Math.abs(array1.length - array2.length),
|
354
|
+
diffs = 0,
|
355
|
+
i;
|
356
|
+
for (i = 0; i < len; i++) {
|
357
|
+
if (~~array1[i] !== ~~array2[i]) {
|
358
|
+
diffs++;
|
359
|
+
}
|
360
|
+
}
|
361
|
+
return diffs + lengthDiff;
|
362
|
+
}
|
363
|
+
|
364
|
+
function normalizeUnits(units) {
|
365
|
+
return units ? unitAliases[units] || units.toLowerCase().replace(/(.)s$/, '$1') : units;
|
366
|
+
}
|
367
|
+
|
368
|
+
|
369
|
+
/************************************
|
370
|
+
Languages
|
371
|
+
************************************/
|
372
|
+
|
373
|
+
|
374
|
+
extend(Language.prototype, {
|
375
|
+
|
376
|
+
set : function (config) {
|
377
|
+
var prop, i;
|
378
|
+
for (i in config) {
|
379
|
+
prop = config[i];
|
380
|
+
if (typeof prop === 'function') {
|
381
|
+
this[i] = prop;
|
382
|
+
} else {
|
383
|
+
this['_' + i] = prop;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
},
|
387
|
+
|
388
|
+
_months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
389
|
+
months : function (m) {
|
390
|
+
return this._months[m.month()];
|
391
|
+
},
|
392
|
+
|
393
|
+
_monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
|
394
|
+
monthsShort : function (m) {
|
395
|
+
return this._monthsShort[m.month()];
|
396
|
+
},
|
397
|
+
|
398
|
+
monthsParse : function (monthName) {
|
399
|
+
var i, mom, regex;
|
400
|
+
|
401
|
+
if (!this._monthsParse) {
|
402
|
+
this._monthsParse = [];
|
403
|
+
}
|
404
|
+
|
405
|
+
for (i = 0; i < 12; i++) {
|
406
|
+
// make the regex if we don't have it already
|
407
|
+
if (!this._monthsParse[i]) {
|
408
|
+
mom = moment.utc([2000, i]);
|
409
|
+
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
410
|
+
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
411
|
+
}
|
412
|
+
// test the regex
|
413
|
+
if (this._monthsParse[i].test(monthName)) {
|
414
|
+
return i;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
},
|
418
|
+
|
419
|
+
_weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
420
|
+
weekdays : function (m) {
|
421
|
+
return this._weekdays[m.day()];
|
422
|
+
},
|
423
|
+
|
424
|
+
_weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
|
425
|
+
weekdaysShort : function (m) {
|
426
|
+
return this._weekdaysShort[m.day()];
|
427
|
+
},
|
428
|
+
|
429
|
+
_weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
|
430
|
+
weekdaysMin : function (m) {
|
431
|
+
return this._weekdaysMin[m.day()];
|
432
|
+
},
|
433
|
+
|
434
|
+
weekdaysParse : function (weekdayName) {
|
435
|
+
var i, mom, regex;
|
436
|
+
|
437
|
+
if (!this._weekdaysParse) {
|
438
|
+
this._weekdaysParse = [];
|
439
|
+
}
|
440
|
+
|
441
|
+
for (i = 0; i < 7; i++) {
|
442
|
+
// make the regex if we don't have it already
|
443
|
+
if (!this._weekdaysParse[i]) {
|
444
|
+
mom = moment([2000, 1]).day(i);
|
445
|
+
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
446
|
+
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
447
|
+
}
|
448
|
+
// test the regex
|
449
|
+
if (this._weekdaysParse[i].test(weekdayName)) {
|
450
|
+
return i;
|
451
|
+
}
|
452
|
+
}
|
453
|
+
},
|
454
|
+
|
455
|
+
_longDateFormat : {
|
456
|
+
LT : "h:mm A",
|
457
|
+
L : "MM/DD/YYYY",
|
458
|
+
LL : "MMMM D YYYY",
|
459
|
+
LLL : "MMMM D YYYY LT",
|
460
|
+
LLLL : "dddd, MMMM D YYYY LT"
|
461
|
+
},
|
462
|
+
longDateFormat : function (key) {
|
463
|
+
var output = this._longDateFormat[key];
|
464
|
+
if (!output && this._longDateFormat[key.toUpperCase()]) {
|
465
|
+
output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
|
466
|
+
return val.slice(1);
|
467
|
+
});
|
468
|
+
this._longDateFormat[key] = output;
|
469
|
+
}
|
470
|
+
return output;
|
471
|
+
},
|
472
|
+
|
473
|
+
isPM : function (input) {
|
474
|
+
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
|
475
|
+
// Using charAt should be more compatible.
|
476
|
+
return ((input + '').toLowerCase().charAt(0) === 'p');
|
477
|
+
},
|
478
|
+
|
479
|
+
_meridiemParse : /[ap]\.?m?\.?/i,
|
480
|
+
meridiem : function (hours, minutes, isLower) {
|
481
|
+
if (hours > 11) {
|
482
|
+
return isLower ? 'pm' : 'PM';
|
483
|
+
} else {
|
484
|
+
return isLower ? 'am' : 'AM';
|
485
|
+
}
|
486
|
+
},
|
487
|
+
|
488
|
+
_calendar : {
|
489
|
+
sameDay : '[Today at] LT',
|
490
|
+
nextDay : '[Tomorrow at] LT',
|
491
|
+
nextWeek : 'dddd [at] LT',
|
492
|
+
lastDay : '[Yesterday at] LT',
|
493
|
+
lastWeek : '[Last] dddd [at] LT',
|
494
|
+
sameElse : 'L'
|
495
|
+
},
|
496
|
+
calendar : function (key, mom) {
|
497
|
+
var output = this._calendar[key];
|
498
|
+
return typeof output === 'function' ? output.apply(mom) : output;
|
499
|
+
},
|
500
|
+
|
501
|
+
_relativeTime : {
|
502
|
+
future : "in %s",
|
503
|
+
past : "%s ago",
|
504
|
+
s : "a few seconds",
|
505
|
+
m : "a minute",
|
506
|
+
mm : "%d minutes",
|
507
|
+
h : "an hour",
|
508
|
+
hh : "%d hours",
|
509
|
+
d : "a day",
|
510
|
+
dd : "%d days",
|
511
|
+
M : "a month",
|
512
|
+
MM : "%d months",
|
513
|
+
y : "a year",
|
514
|
+
yy : "%d years"
|
515
|
+
},
|
516
|
+
relativeTime : function (number, withoutSuffix, string, isFuture) {
|
517
|
+
var output = this._relativeTime[string];
|
518
|
+
return (typeof output === 'function') ?
|
519
|
+
output(number, withoutSuffix, string, isFuture) :
|
520
|
+
output.replace(/%d/i, number);
|
521
|
+
},
|
522
|
+
pastFuture : function (diff, output) {
|
523
|
+
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
524
|
+
return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
|
525
|
+
},
|
526
|
+
|
527
|
+
ordinal : function (number) {
|
528
|
+
return this._ordinal.replace("%d", number);
|
529
|
+
},
|
530
|
+
_ordinal : "%d",
|
531
|
+
|
532
|
+
preparse : function (string) {
|
533
|
+
return string;
|
534
|
+
},
|
535
|
+
|
536
|
+
postformat : function (string) {
|
537
|
+
return string;
|
538
|
+
},
|
539
|
+
|
540
|
+
week : function (mom) {
|
541
|
+
return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
542
|
+
},
|
543
|
+
_week : {
|
544
|
+
dow : 0, // Sunday is the first day of the week.
|
545
|
+
doy : 6 // The week that contains Jan 1st is the first week of the year.
|
546
|
+
}
|
547
|
+
});
|
548
|
+
|
549
|
+
// Loads a language definition into the `languages` cache. The function
|
550
|
+
// takes a key and optionally values. If not in the browser and no values
|
551
|
+
// are provided, it will load the language file module. As a convenience,
|
552
|
+
// this function also returns the language values.
|
553
|
+
function loadLang(key, values) {
|
554
|
+
values.abbr = key;
|
555
|
+
if (!languages[key]) {
|
556
|
+
languages[key] = new Language();
|
557
|
+
}
|
558
|
+
languages[key].set(values);
|
559
|
+
return languages[key];
|
560
|
+
}
|
561
|
+
|
562
|
+
// Remove a language from the `languages` cache. Mostly useful in tests.
|
563
|
+
function unloadLang(key) {
|
564
|
+
delete languages[key];
|
565
|
+
}
|
566
|
+
|
567
|
+
// Determines which language definition to use and returns it.
|
568
|
+
//
|
569
|
+
// With no parameters, it will return the global language. If you
|
570
|
+
// pass in a language key, such as 'en', it will return the
|
571
|
+
// definition for 'en', so long as 'en' has already been loaded using
|
572
|
+
// moment.lang.
|
573
|
+
function getLangDefinition(key) {
|
574
|
+
if (!key) {
|
575
|
+
return moment.fn._lang;
|
576
|
+
}
|
577
|
+
if (!languages[key] && hasModule) {
|
578
|
+
try {
|
579
|
+
require('./lang/' + key);
|
580
|
+
} catch (e) {
|
581
|
+
// call with no params to set to default
|
582
|
+
return moment.fn._lang;
|
583
|
+
}
|
584
|
+
}
|
585
|
+
return languages[key] || moment.fn._lang;
|
586
|
+
}
|
587
|
+
|
588
|
+
|
589
|
+
/************************************
|
590
|
+
Formatting
|
591
|
+
************************************/
|
592
|
+
|
593
|
+
|
594
|
+
function removeFormattingTokens(input) {
|
595
|
+
if (input.match(/\[.*\]/)) {
|
596
|
+
return input.replace(/^\[|\]$/g, "");
|
597
|
+
}
|
598
|
+
return input.replace(/\\/g, "");
|
599
|
+
}
|
600
|
+
|
601
|
+
function makeFormatFunction(format) {
|
602
|
+
var array = format.match(formattingTokens), i, length;
|
603
|
+
|
604
|
+
for (i = 0, length = array.length; i < length; i++) {
|
605
|
+
if (formatTokenFunctions[array[i]]) {
|
606
|
+
array[i] = formatTokenFunctions[array[i]];
|
607
|
+
} else {
|
608
|
+
array[i] = removeFormattingTokens(array[i]);
|
609
|
+
}
|
610
|
+
}
|
611
|
+
|
612
|
+
return function (mom) {
|
613
|
+
var output = "";
|
614
|
+
for (i = 0; i < length; i++) {
|
615
|
+
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
|
616
|
+
}
|
617
|
+
return output;
|
618
|
+
};
|
619
|
+
}
|
620
|
+
|
621
|
+
// format date using native date object
|
622
|
+
function formatMoment(m, format) {
|
623
|
+
|
624
|
+
format = expandFormat(format, m.lang());
|
625
|
+
|
626
|
+
if (!formatFunctions[format]) {
|
627
|
+
formatFunctions[format] = makeFormatFunction(format);
|
628
|
+
}
|
629
|
+
|
630
|
+
return formatFunctions[format](m);
|
631
|
+
}
|
632
|
+
|
633
|
+
function expandFormat(format, lang) {
|
634
|
+
var i = 5;
|
635
|
+
|
636
|
+
function replaceLongDateFormatTokens(input) {
|
637
|
+
return lang.longDateFormat(input) || input;
|
638
|
+
}
|
639
|
+
|
640
|
+
while (i-- && (localFormattingTokens.lastIndex = 0,
|
641
|
+
localFormattingTokens.test(format))) {
|
642
|
+
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
643
|
+
}
|
644
|
+
|
645
|
+
return format;
|
646
|
+
}
|
647
|
+
|
648
|
+
|
649
|
+
/************************************
|
650
|
+
Parsing
|
651
|
+
************************************/
|
652
|
+
|
653
|
+
|
654
|
+
// get the regex to find the next token
|
655
|
+
function getParseRegexForToken(token, config) {
|
656
|
+
switch (token) {
|
657
|
+
case 'DDDD':
|
658
|
+
return parseTokenThreeDigits;
|
659
|
+
case 'YYYY':
|
660
|
+
return parseTokenFourDigits;
|
661
|
+
case 'YYYYY':
|
662
|
+
return parseTokenSixDigits;
|
663
|
+
case 'S':
|
664
|
+
case 'SS':
|
665
|
+
case 'SSS':
|
666
|
+
case 'DDD':
|
667
|
+
return parseTokenOneToThreeDigits;
|
668
|
+
case 'MMM':
|
669
|
+
case 'MMMM':
|
670
|
+
case 'dd':
|
671
|
+
case 'ddd':
|
672
|
+
case 'dddd':
|
673
|
+
return parseTokenWord;
|
674
|
+
case 'a':
|
675
|
+
case 'A':
|
676
|
+
return getLangDefinition(config._l)._meridiemParse;
|
677
|
+
case 'X':
|
678
|
+
return parseTokenTimestampMs;
|
679
|
+
case 'Z':
|
680
|
+
case 'ZZ':
|
681
|
+
return parseTokenTimezone;
|
682
|
+
case 'T':
|
683
|
+
return parseTokenT;
|
684
|
+
case 'MM':
|
685
|
+
case 'DD':
|
686
|
+
case 'YY':
|
687
|
+
case 'HH':
|
688
|
+
case 'hh':
|
689
|
+
case 'mm':
|
690
|
+
case 'ss':
|
691
|
+
case 'M':
|
692
|
+
case 'D':
|
693
|
+
case 'd':
|
694
|
+
case 'H':
|
695
|
+
case 'h':
|
696
|
+
case 'm':
|
697
|
+
case 's':
|
698
|
+
return parseTokenOneOrTwoDigits;
|
699
|
+
default :
|
700
|
+
return new RegExp(token.replace('\\', ''));
|
701
|
+
}
|
702
|
+
}
|
703
|
+
|
704
|
+
function timezoneMinutesFromString(string) {
|
705
|
+
var tzchunk = (parseTokenTimezone.exec(string) || [])[0],
|
706
|
+
parts = (tzchunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
|
707
|
+
minutes = +(parts[1] * 60) + ~~parts[2];
|
708
|
+
|
709
|
+
return parts[0] === '+' ? -minutes : minutes;
|
710
|
+
}
|
711
|
+
|
712
|
+
// function to convert string input to date
|
713
|
+
function addTimeToArrayFromToken(token, input, config) {
|
714
|
+
var a, datePartArray = config._a;
|
715
|
+
|
716
|
+
switch (token) {
|
717
|
+
// MONTH
|
718
|
+
case 'M' : // fall through to MM
|
719
|
+
case 'MM' :
|
720
|
+
if (input != null) {
|
721
|
+
datePartArray[1] = ~~input - 1;
|
722
|
+
}
|
723
|
+
break;
|
724
|
+
case 'MMM' : // fall through to MMMM
|
725
|
+
case 'MMMM' :
|
726
|
+
a = getLangDefinition(config._l).monthsParse(input);
|
727
|
+
// if we didn't find a month name, mark the date as invalid.
|
728
|
+
if (a != null) {
|
729
|
+
datePartArray[1] = a;
|
730
|
+
} else {
|
731
|
+
config._isValid = false;
|
732
|
+
}
|
733
|
+
break;
|
734
|
+
// DAY OF MONTH
|
735
|
+
case 'D' : // fall through to DD
|
736
|
+
case 'DD' :
|
737
|
+
if (input != null) {
|
738
|
+
datePartArray[2] = ~~input;
|
739
|
+
}
|
740
|
+
break;
|
741
|
+
// DAY OF YEAR
|
742
|
+
case 'DDD' : // fall through to DDDD
|
743
|
+
case 'DDDD' :
|
744
|
+
if (input != null) {
|
745
|
+
datePartArray[1] = 0;
|
746
|
+
datePartArray[2] = ~~input;
|
747
|
+
}
|
748
|
+
break;
|
749
|
+
// YEAR
|
750
|
+
case 'YY' :
|
751
|
+
datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000);
|
752
|
+
break;
|
753
|
+
case 'YYYY' :
|
754
|
+
case 'YYYYY' :
|
755
|
+
datePartArray[0] = ~~input;
|
756
|
+
break;
|
757
|
+
// AM / PM
|
758
|
+
case 'a' : // fall through to A
|
759
|
+
case 'A' :
|
760
|
+
config._isPm = getLangDefinition(config._l).isPM(input);
|
761
|
+
break;
|
762
|
+
// 24 HOUR
|
763
|
+
case 'H' : // fall through to hh
|
764
|
+
case 'HH' : // fall through to hh
|
765
|
+
case 'h' : // fall through to hh
|
766
|
+
case 'hh' :
|
767
|
+
datePartArray[3] = ~~input;
|
768
|
+
break;
|
769
|
+
// MINUTE
|
770
|
+
case 'm' : // fall through to mm
|
771
|
+
case 'mm' :
|
772
|
+
datePartArray[4] = ~~input;
|
773
|
+
break;
|
774
|
+
// SECOND
|
775
|
+
case 's' : // fall through to ss
|
776
|
+
case 'ss' :
|
777
|
+
datePartArray[5] = ~~input;
|
778
|
+
break;
|
779
|
+
// MILLISECOND
|
780
|
+
case 'S' :
|
781
|
+
case 'SS' :
|
782
|
+
case 'SSS' :
|
783
|
+
datePartArray[6] = ~~ (('0.' + input) * 1000);
|
784
|
+
break;
|
785
|
+
// UNIX TIMESTAMP WITH MS
|
786
|
+
case 'X':
|
787
|
+
config._d = new Date(parseFloat(input) * 1000);
|
788
|
+
break;
|
789
|
+
// TIMEZONE
|
790
|
+
case 'Z' : // fall through to ZZ
|
791
|
+
case 'ZZ' :
|
792
|
+
config._useUTC = true;
|
793
|
+
config._tzm = timezoneMinutesFromString(input);
|
794
|
+
break;
|
795
|
+
}
|
796
|
+
|
797
|
+
// if the input is null, the date is not valid
|
798
|
+
if (input == null) {
|
799
|
+
config._isValid = false;
|
800
|
+
}
|
801
|
+
}
|
802
|
+
|
803
|
+
// convert an array to a date.
|
804
|
+
// the array should mirror the parameters below
|
805
|
+
// note: all values past the year are optional and will default to the lowest possible value.
|
806
|
+
// [year, month, day , hour, minute, second, millisecond]
|
807
|
+
function dateFromArray(config) {
|
808
|
+
var i, date, input = [], currentDate;
|
809
|
+
|
810
|
+
if (config._d) {
|
811
|
+
return;
|
812
|
+
}
|
813
|
+
|
814
|
+
// Default to current date.
|
815
|
+
// * if no year, month, day of month are given, default to today
|
816
|
+
// * if day of month is given, default month and year
|
817
|
+
// * if month is given, default only year
|
818
|
+
// * if year is given, don't default anything
|
819
|
+
currentDate = currentDateArray(config);
|
820
|
+
for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
821
|
+
config._a[i] = input[i] = currentDate[i];
|
822
|
+
}
|
823
|
+
|
824
|
+
// Zero out whatever was not defaulted, including time
|
825
|
+
for (; i < 7; i++) {
|
826
|
+
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
|
827
|
+
}
|
828
|
+
|
829
|
+
// add the offsets to the time to be parsed so that we can have a clean array for checking isValid
|
830
|
+
input[3] += ~~((config._tzm || 0) / 60);
|
831
|
+
input[4] += ~~((config._tzm || 0) % 60);
|
832
|
+
|
833
|
+
date = new Date(0);
|
834
|
+
|
835
|
+
if (config._useUTC) {
|
836
|
+
date.setUTCFullYear(input[0], input[1], input[2]);
|
837
|
+
date.setUTCHours(input[3], input[4], input[5], input[6]);
|
838
|
+
} else {
|
839
|
+
date.setFullYear(input[0], input[1], input[2]);
|
840
|
+
date.setHours(input[3], input[4], input[5], input[6]);
|
841
|
+
}
|
842
|
+
|
843
|
+
config._d = date;
|
844
|
+
}
|
845
|
+
|
846
|
+
function dateFromObject(config) {
|
847
|
+
var o = config._i;
|
848
|
+
|
849
|
+
if (config._d) {
|
850
|
+
return;
|
851
|
+
}
|
852
|
+
|
853
|
+
config._a = [
|
854
|
+
o.years || o.year || o.y,
|
855
|
+
o.months || o.month || o.M,
|
856
|
+
o.days || o.day || o.d,
|
857
|
+
o.hours || o.hour || o.h,
|
858
|
+
o.minutes || o.minute || o.m,
|
859
|
+
o.seconds || o.second || o.s,
|
860
|
+
o.milliseconds || o.millisecond || o.ms
|
861
|
+
];
|
862
|
+
|
863
|
+
dateFromArray(config);
|
864
|
+
}
|
865
|
+
|
866
|
+
function currentDateArray(config) {
|
867
|
+
var now = new Date();
|
868
|
+
if (config._useUTC) {
|
869
|
+
return [
|
870
|
+
now.getUTCFullYear(),
|
871
|
+
now.getUTCMonth(),
|
872
|
+
now.getUTCDate()
|
873
|
+
];
|
874
|
+
} else {
|
875
|
+
return [now.getFullYear(), now.getMonth(), now.getDate()];
|
876
|
+
}
|
877
|
+
}
|
878
|
+
|
879
|
+
// date from string and format string
|
880
|
+
function makeDateFromStringAndFormat(config) {
|
881
|
+
// This array is used to make a Date, either with `new Date` or `Date.UTC`
|
882
|
+
var lang = getLangDefinition(config._l),
|
883
|
+
string = '' + config._i,
|
884
|
+
i, parsedInput, tokens;
|
885
|
+
|
886
|
+
tokens = expandFormat(config._f, lang).match(formattingTokens);
|
887
|
+
|
888
|
+
config._a = [];
|
889
|
+
|
890
|
+
for (i = 0; i < tokens.length; i++) {
|
891
|
+
parsedInput = (getParseRegexForToken(tokens[i], config).exec(string) || [])[0];
|
892
|
+
if (parsedInput) {
|
893
|
+
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
894
|
+
}
|
895
|
+
// don't parse if its not a known token
|
896
|
+
if (formatTokenFunctions[tokens[i]]) {
|
897
|
+
addTimeToArrayFromToken(tokens[i], parsedInput, config);
|
898
|
+
}
|
899
|
+
}
|
900
|
+
|
901
|
+
// add remaining unparsed input to the string
|
902
|
+
if (string) {
|
903
|
+
config._il = string;
|
904
|
+
}
|
905
|
+
|
906
|
+
// handle am pm
|
907
|
+
if (config._isPm && config._a[3] < 12) {
|
908
|
+
config._a[3] += 12;
|
909
|
+
}
|
910
|
+
// if is 12 am, change hours to 0
|
911
|
+
if (config._isPm === false && config._a[3] === 12) {
|
912
|
+
config._a[3] = 0;
|
913
|
+
}
|
914
|
+
// return
|
915
|
+
dateFromArray(config);
|
916
|
+
}
|
917
|
+
|
918
|
+
// date from string and array of format strings
|
919
|
+
function makeDateFromStringAndArray(config) {
|
920
|
+
var tempConfig,
|
921
|
+
tempMoment,
|
922
|
+
bestMoment,
|
923
|
+
|
924
|
+
scoreToBeat = 99,
|
925
|
+
i,
|
926
|
+
currentScore;
|
927
|
+
|
928
|
+
for (i = 0; i < config._f.length; i++) {
|
929
|
+
tempConfig = extend({}, config);
|
930
|
+
tempConfig._f = config._f[i];
|
931
|
+
makeDateFromStringAndFormat(tempConfig);
|
932
|
+
tempMoment = new Moment(tempConfig);
|
933
|
+
|
934
|
+
currentScore = compareArrays(tempConfig._a, tempMoment.toArray());
|
935
|
+
|
936
|
+
// if there is any input that was not parsed
|
937
|
+
// add a penalty for that format
|
938
|
+
if (tempMoment._il) {
|
939
|
+
currentScore += tempMoment._il.length;
|
940
|
+
}
|
941
|
+
|
942
|
+
if (currentScore < scoreToBeat) {
|
943
|
+
scoreToBeat = currentScore;
|
944
|
+
bestMoment = tempMoment;
|
945
|
+
}
|
946
|
+
}
|
947
|
+
|
948
|
+
extend(config, bestMoment);
|
949
|
+
}
|
950
|
+
|
951
|
+
// date from iso format
|
952
|
+
function makeDateFromString(config) {
|
953
|
+
var i,
|
954
|
+
string = config._i,
|
955
|
+
match = isoRegex.exec(string);
|
956
|
+
|
957
|
+
if (match) {
|
958
|
+
// match[2] should be "T" or undefined
|
959
|
+
config._f = 'YYYY-MM-DD' + (match[2] || " ");
|
960
|
+
for (i = 0; i < 4; i++) {
|
961
|
+
if (isoTimes[i][1].exec(string)) {
|
962
|
+
config._f += isoTimes[i][0];
|
963
|
+
break;
|
964
|
+
}
|
965
|
+
}
|
966
|
+
if (parseTokenTimezone.exec(string)) {
|
967
|
+
config._f += " Z";
|
968
|
+
}
|
969
|
+
makeDateFromStringAndFormat(config);
|
970
|
+
} else {
|
971
|
+
config._d = new Date(string);
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
function makeDateFromInput(config) {
|
976
|
+
var input = config._i,
|
977
|
+
matched = aspNetJsonRegex.exec(input);
|
978
|
+
|
979
|
+
if (input === undefined) {
|
980
|
+
config._d = new Date();
|
981
|
+
} else if (matched) {
|
982
|
+
config._d = new Date(+matched[1]);
|
983
|
+
} else if (typeof input === 'string') {
|
984
|
+
makeDateFromString(config);
|
985
|
+
} else if (isArray(input)) {
|
986
|
+
config._a = input.slice(0);
|
987
|
+
dateFromArray(config);
|
988
|
+
} else if (input instanceof Date) {
|
989
|
+
config._d = new Date(+input);
|
990
|
+
} else if (typeof(input) === 'object') {
|
991
|
+
dateFromObject(config);
|
992
|
+
} else {
|
993
|
+
config._d = new Date(input);
|
994
|
+
}
|
995
|
+
}
|
996
|
+
|
997
|
+
|
998
|
+
/************************************
|
999
|
+
Relative Time
|
1000
|
+
************************************/
|
1001
|
+
|
1002
|
+
|
1003
|
+
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
|
1004
|
+
function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) {
|
1005
|
+
return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
function relativeTime(milliseconds, withoutSuffix, lang) {
|
1009
|
+
var seconds = round(Math.abs(milliseconds) / 1000),
|
1010
|
+
minutes = round(seconds / 60),
|
1011
|
+
hours = round(minutes / 60),
|
1012
|
+
days = round(hours / 24),
|
1013
|
+
years = round(days / 365),
|
1014
|
+
args = seconds < 45 && ['s', seconds] ||
|
1015
|
+
minutes === 1 && ['m'] ||
|
1016
|
+
minutes < 45 && ['mm', minutes] ||
|
1017
|
+
hours === 1 && ['h'] ||
|
1018
|
+
hours < 22 && ['hh', hours] ||
|
1019
|
+
days === 1 && ['d'] ||
|
1020
|
+
days <= 25 && ['dd', days] ||
|
1021
|
+
days <= 45 && ['M'] ||
|
1022
|
+
days < 345 && ['MM', round(days / 30)] ||
|
1023
|
+
years === 1 && ['y'] || ['yy', years];
|
1024
|
+
args[2] = withoutSuffix;
|
1025
|
+
args[3] = milliseconds > 0;
|
1026
|
+
args[4] = lang;
|
1027
|
+
return substituteTimeAgo.apply({}, args);
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
|
1031
|
+
/************************************
|
1032
|
+
Week of Year
|
1033
|
+
************************************/
|
1034
|
+
|
1035
|
+
|
1036
|
+
// firstDayOfWeek 0 = sun, 6 = sat
|
1037
|
+
// the day of the week that starts the week
|
1038
|
+
// (usually sunday or monday)
|
1039
|
+
// firstDayOfWeekOfYear 0 = sun, 6 = sat
|
1040
|
+
// the first week is the week that contains the first
|
1041
|
+
// of this day of the week
|
1042
|
+
// (eg. ISO weeks use thursday (4))
|
1043
|
+
function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
|
1044
|
+
var end = firstDayOfWeekOfYear - firstDayOfWeek,
|
1045
|
+
daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
|
1046
|
+
adjustedMoment;
|
1047
|
+
|
1048
|
+
|
1049
|
+
if (daysToDayOfWeek > end) {
|
1050
|
+
daysToDayOfWeek -= 7;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
if (daysToDayOfWeek < end - 7) {
|
1054
|
+
daysToDayOfWeek += 7;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
adjustedMoment = moment(mom).add('d', daysToDayOfWeek);
|
1058
|
+
return {
|
1059
|
+
week: Math.ceil(adjustedMoment.dayOfYear() / 7),
|
1060
|
+
year: adjustedMoment.year()
|
1061
|
+
};
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
|
1065
|
+
/************************************
|
1066
|
+
Top Level Functions
|
1067
|
+
************************************/
|
1068
|
+
|
1069
|
+
function makeMoment(config) {
|
1070
|
+
var input = config._i,
|
1071
|
+
format = config._f;
|
1072
|
+
|
1073
|
+
if (input === null || input === '') {
|
1074
|
+
return null;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
if (typeof input === 'string') {
|
1078
|
+
config._i = input = getLangDefinition().preparse(input);
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
if (moment.isMoment(input)) {
|
1082
|
+
config = extend({}, input);
|
1083
|
+
config._d = new Date(+input._d);
|
1084
|
+
} else if (format) {
|
1085
|
+
if (isArray(format)) {
|
1086
|
+
makeDateFromStringAndArray(config);
|
1087
|
+
} else {
|
1088
|
+
makeDateFromStringAndFormat(config);
|
1089
|
+
}
|
1090
|
+
} else {
|
1091
|
+
makeDateFromInput(config);
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
return new Moment(config);
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
moment = function (input, format, lang) {
|
1098
|
+
return makeMoment({
|
1099
|
+
_i : input,
|
1100
|
+
_f : format,
|
1101
|
+
_l : lang,
|
1102
|
+
_isUTC : false
|
1103
|
+
});
|
1104
|
+
};
|
1105
|
+
|
1106
|
+
// creating with utc
|
1107
|
+
moment.utc = function (input, format, lang) {
|
1108
|
+
return makeMoment({
|
1109
|
+
_useUTC : true,
|
1110
|
+
_isUTC : true,
|
1111
|
+
_l : lang,
|
1112
|
+
_i : input,
|
1113
|
+
_f : format
|
1114
|
+
}).utc();
|
1115
|
+
};
|
1116
|
+
|
1117
|
+
// creating with unix timestamp (in seconds)
|
1118
|
+
moment.unix = function (input) {
|
1119
|
+
return moment(input * 1000);
|
1120
|
+
};
|
1121
|
+
|
1122
|
+
// duration
|
1123
|
+
moment.duration = function (input, key) {
|
1124
|
+
var isDuration = moment.isDuration(input),
|
1125
|
+
isNumber = (typeof input === 'number'),
|
1126
|
+
duration = (isDuration ? input._input : (isNumber ? {} : input)),
|
1127
|
+
matched = aspNetTimeSpanJsonRegex.exec(input),
|
1128
|
+
sign,
|
1129
|
+
ret;
|
1130
|
+
|
1131
|
+
if (isNumber) {
|
1132
|
+
if (key) {
|
1133
|
+
duration[key] = input;
|
1134
|
+
} else {
|
1135
|
+
duration.milliseconds = input;
|
1136
|
+
}
|
1137
|
+
} else if (matched) {
|
1138
|
+
sign = (matched[1] === "-") ? -1 : 1;
|
1139
|
+
duration = {
|
1140
|
+
y: 0,
|
1141
|
+
d: ~~matched[2] * sign,
|
1142
|
+
h: ~~matched[3] * sign,
|
1143
|
+
m: ~~matched[4] * sign,
|
1144
|
+
s: ~~matched[5] * sign,
|
1145
|
+
ms: ~~matched[6] * sign
|
1146
|
+
};
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
ret = new Duration(duration);
|
1150
|
+
|
1151
|
+
if (isDuration && input.hasOwnProperty('_lang')) {
|
1152
|
+
ret._lang = input._lang;
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
return ret;
|
1156
|
+
};
|
1157
|
+
|
1158
|
+
// version number
|
1159
|
+
moment.version = VERSION;
|
1160
|
+
|
1161
|
+
// default format
|
1162
|
+
moment.defaultFormat = isoFormat;
|
1163
|
+
|
1164
|
+
// This function will be called whenever a moment is mutated.
|
1165
|
+
// It is intended to keep the offset in sync with the timezone.
|
1166
|
+
moment.updateOffset = function () {};
|
1167
|
+
|
1168
|
+
// This function will load languages and then set the global language. If
|
1169
|
+
// no arguments are passed in, it will simply return the current global
|
1170
|
+
// language key.
|
1171
|
+
moment.lang = function (key, values) {
|
1172
|
+
if (!key) {
|
1173
|
+
return moment.fn._lang._abbr;
|
1174
|
+
}
|
1175
|
+
key = key.toLowerCase();
|
1176
|
+
key = key.replace('_', '-');
|
1177
|
+
if (values) {
|
1178
|
+
loadLang(key, values);
|
1179
|
+
} else if (values === null) {
|
1180
|
+
unloadLang(key);
|
1181
|
+
key = 'en';
|
1182
|
+
} else if (!languages[key]) {
|
1183
|
+
getLangDefinition(key);
|
1184
|
+
}
|
1185
|
+
moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
// returns language data
|
1189
|
+
moment.langData = function (key) {
|
1190
|
+
if (key && key._lang && key._lang._abbr) {
|
1191
|
+
key = key._lang._abbr;
|
1192
|
+
}
|
1193
|
+
return getLangDefinition(key);
|
1194
|
+
};
|
1195
|
+
|
1196
|
+
// compare moment object
|
1197
|
+
moment.isMoment = function (obj) {
|
1198
|
+
return obj instanceof Moment;
|
1199
|
+
};
|
1200
|
+
|
1201
|
+
// for typechecking Duration objects
|
1202
|
+
moment.isDuration = function (obj) {
|
1203
|
+
return obj instanceof Duration;
|
1204
|
+
};
|
1205
|
+
|
1206
|
+
|
1207
|
+
/************************************
|
1208
|
+
Moment Prototype
|
1209
|
+
************************************/
|
1210
|
+
|
1211
|
+
|
1212
|
+
extend(moment.fn = Moment.prototype, {
|
1213
|
+
|
1214
|
+
clone : function () {
|
1215
|
+
return moment(this);
|
1216
|
+
},
|
1217
|
+
|
1218
|
+
valueOf : function () {
|
1219
|
+
return +this._d + ((this._offset || 0) * 60000);
|
1220
|
+
},
|
1221
|
+
|
1222
|
+
unix : function () {
|
1223
|
+
return Math.floor(+this / 1000);
|
1224
|
+
},
|
1225
|
+
|
1226
|
+
toString : function () {
|
1227
|
+
return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
|
1228
|
+
},
|
1229
|
+
|
1230
|
+
toDate : function () {
|
1231
|
+
return this._offset ? new Date(+this) : this._d;
|
1232
|
+
},
|
1233
|
+
|
1234
|
+
toISOString : function () {
|
1235
|
+
return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
|
1236
|
+
},
|
1237
|
+
|
1238
|
+
toArray : function () {
|
1239
|
+
var m = this;
|
1240
|
+
return [
|
1241
|
+
m.year(),
|
1242
|
+
m.month(),
|
1243
|
+
m.date(),
|
1244
|
+
m.hours(),
|
1245
|
+
m.minutes(),
|
1246
|
+
m.seconds(),
|
1247
|
+
m.milliseconds()
|
1248
|
+
];
|
1249
|
+
},
|
1250
|
+
|
1251
|
+
isValid : function () {
|
1252
|
+
if (this._isValid == null) {
|
1253
|
+
if (this._a) {
|
1254
|
+
this._isValid = !compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray());
|
1255
|
+
} else {
|
1256
|
+
this._isValid = !isNaN(this._d.getTime());
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
return !!this._isValid;
|
1260
|
+
},
|
1261
|
+
|
1262
|
+
invalidAt: function () {
|
1263
|
+
var i, arr1 = this._a, arr2 = (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray();
|
1264
|
+
for (i = 6; i >= 0 && arr1[i] === arr2[i]; --i) {
|
1265
|
+
// empty loop body
|
1266
|
+
}
|
1267
|
+
return i;
|
1268
|
+
},
|
1269
|
+
|
1270
|
+
utc : function () {
|
1271
|
+
return this.zone(0);
|
1272
|
+
},
|
1273
|
+
|
1274
|
+
local : function () {
|
1275
|
+
this.zone(0);
|
1276
|
+
this._isUTC = false;
|
1277
|
+
return this;
|
1278
|
+
},
|
1279
|
+
|
1280
|
+
format : function (inputString) {
|
1281
|
+
var output = formatMoment(this, inputString || moment.defaultFormat);
|
1282
|
+
return this.lang().postformat(output);
|
1283
|
+
},
|
1284
|
+
|
1285
|
+
add : function (input, val) {
|
1286
|
+
var dur;
|
1287
|
+
// switch args to support add('s', 1) and add(1, 's')
|
1288
|
+
if (typeof input === 'string') {
|
1289
|
+
dur = moment.duration(+val, input);
|
1290
|
+
} else {
|
1291
|
+
dur = moment.duration(input, val);
|
1292
|
+
}
|
1293
|
+
addOrSubtractDurationFromMoment(this, dur, 1);
|
1294
|
+
return this;
|
1295
|
+
},
|
1296
|
+
|
1297
|
+
subtract : function (input, val) {
|
1298
|
+
var dur;
|
1299
|
+
// switch args to support subtract('s', 1) and subtract(1, 's')
|
1300
|
+
if (typeof input === 'string') {
|
1301
|
+
dur = moment.duration(+val, input);
|
1302
|
+
} else {
|
1303
|
+
dur = moment.duration(input, val);
|
1304
|
+
}
|
1305
|
+
addOrSubtractDurationFromMoment(this, dur, -1);
|
1306
|
+
return this;
|
1307
|
+
},
|
1308
|
+
|
1309
|
+
diff : function (input, units, asFloat) {
|
1310
|
+
var that = this._isUTC ? moment(input).zone(this._offset || 0) : moment(input).local(),
|
1311
|
+
zoneDiff = (this.zone() - that.zone()) * 6e4,
|
1312
|
+
diff, output;
|
1313
|
+
|
1314
|
+
units = normalizeUnits(units);
|
1315
|
+
|
1316
|
+
if (units === 'year' || units === 'month') {
|
1317
|
+
// average number of days in the months in the given dates
|
1318
|
+
diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
|
1319
|
+
// difference in months
|
1320
|
+
output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
|
1321
|
+
// adjust by taking difference in days, average number of days
|
1322
|
+
// and dst in the given months.
|
1323
|
+
output += ((this - moment(this).startOf('month')) -
|
1324
|
+
(that - moment(that).startOf('month'))) / diff;
|
1325
|
+
// same as above but with zones, to negate all dst
|
1326
|
+
output -= ((this.zone() - moment(this).startOf('month').zone()) -
|
1327
|
+
(that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
|
1328
|
+
if (units === 'year') {
|
1329
|
+
output = output / 12;
|
1330
|
+
}
|
1331
|
+
} else {
|
1332
|
+
diff = (this - that);
|
1333
|
+
output = units === 'second' ? diff / 1e3 : // 1000
|
1334
|
+
units === 'minute' ? diff / 6e4 : // 1000 * 60
|
1335
|
+
units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
|
1336
|
+
units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
|
1337
|
+
units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
|
1338
|
+
diff;
|
1339
|
+
}
|
1340
|
+
return asFloat ? output : absRound(output);
|
1341
|
+
},
|
1342
|
+
|
1343
|
+
from : function (time, withoutSuffix) {
|
1344
|
+
return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix);
|
1345
|
+
},
|
1346
|
+
|
1347
|
+
fromNow : function (withoutSuffix) {
|
1348
|
+
return this.from(moment(), withoutSuffix);
|
1349
|
+
},
|
1350
|
+
|
1351
|
+
calendar : function () {
|
1352
|
+
var diff = this.diff(moment().zone(this.zone()).startOf('day'), 'days', true),
|
1353
|
+
format = diff < -6 ? 'sameElse' :
|
1354
|
+
diff < -1 ? 'lastWeek' :
|
1355
|
+
diff < 0 ? 'lastDay' :
|
1356
|
+
diff < 1 ? 'sameDay' :
|
1357
|
+
diff < 2 ? 'nextDay' :
|
1358
|
+
diff < 7 ? 'nextWeek' : 'sameElse';
|
1359
|
+
return this.format(this.lang().calendar(format, this));
|
1360
|
+
},
|
1361
|
+
|
1362
|
+
isLeapYear : function () {
|
1363
|
+
var year = this.year();
|
1364
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
1365
|
+
},
|
1366
|
+
|
1367
|
+
isDST : function () {
|
1368
|
+
return (this.zone() < this.clone().month(0).zone() ||
|
1369
|
+
this.zone() < this.clone().month(5).zone());
|
1370
|
+
},
|
1371
|
+
|
1372
|
+
day : function (input) {
|
1373
|
+
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
1374
|
+
if (input != null) {
|
1375
|
+
if (typeof input === 'string') {
|
1376
|
+
input = this.lang().weekdaysParse(input);
|
1377
|
+
if (typeof input !== 'number') {
|
1378
|
+
return this;
|
1379
|
+
}
|
1380
|
+
}
|
1381
|
+
return this.add({ d : input - day });
|
1382
|
+
} else {
|
1383
|
+
return day;
|
1384
|
+
}
|
1385
|
+
},
|
1386
|
+
|
1387
|
+
month : function (input) {
|
1388
|
+
var utc = this._isUTC ? 'UTC' : '',
|
1389
|
+
dayOfMonth;
|
1390
|
+
|
1391
|
+
if (input != null) {
|
1392
|
+
if (typeof input === 'string') {
|
1393
|
+
input = this.lang().monthsParse(input);
|
1394
|
+
if (typeof input !== 'number') {
|
1395
|
+
return this;
|
1396
|
+
}
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
dayOfMonth = this.date();
|
1400
|
+
this.date(1);
|
1401
|
+
this._d['set' + utc + 'Month'](input);
|
1402
|
+
this.date(Math.min(dayOfMonth, this.daysInMonth()));
|
1403
|
+
|
1404
|
+
moment.updateOffset(this);
|
1405
|
+
return this;
|
1406
|
+
} else {
|
1407
|
+
return this._d['get' + utc + 'Month']();
|
1408
|
+
}
|
1409
|
+
},
|
1410
|
+
|
1411
|
+
startOf: function (units) {
|
1412
|
+
units = normalizeUnits(units);
|
1413
|
+
// the following switch intentionally omits break keywords
|
1414
|
+
// to utilize falling through the cases.
|
1415
|
+
switch (units) {
|
1416
|
+
case 'year':
|
1417
|
+
this.month(0);
|
1418
|
+
/* falls through */
|
1419
|
+
case 'month':
|
1420
|
+
this.date(1);
|
1421
|
+
/* falls through */
|
1422
|
+
case 'week':
|
1423
|
+
case 'isoweek':
|
1424
|
+
case 'day':
|
1425
|
+
this.hours(0);
|
1426
|
+
/* falls through */
|
1427
|
+
case 'hour':
|
1428
|
+
this.minutes(0);
|
1429
|
+
/* falls through */
|
1430
|
+
case 'minute':
|
1431
|
+
this.seconds(0);
|
1432
|
+
/* falls through */
|
1433
|
+
case 'second':
|
1434
|
+
this.milliseconds(0);
|
1435
|
+
/* falls through */
|
1436
|
+
}
|
1437
|
+
|
1438
|
+
// weeks are a special case
|
1439
|
+
if (units === 'week') {
|
1440
|
+
this.weekday(0);
|
1441
|
+
} else if (units === 'isoweek') {
|
1442
|
+
this.isoWeekday(1);
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
return this;
|
1446
|
+
},
|
1447
|
+
|
1448
|
+
endOf: function (units) {
|
1449
|
+
units = normalizeUnits(units);
|
1450
|
+
return this.startOf(units).add((units === 'isoweek' ? 'week' : units), 1).subtract('ms', 1);
|
1451
|
+
},
|
1452
|
+
|
1453
|
+
isAfter: function (input, units) {
|
1454
|
+
units = typeof units !== 'undefined' ? units : 'millisecond';
|
1455
|
+
return +this.clone().startOf(units) > +moment(input).startOf(units);
|
1456
|
+
},
|
1457
|
+
|
1458
|
+
isBefore: function (input, units) {
|
1459
|
+
units = typeof units !== 'undefined' ? units : 'millisecond';
|
1460
|
+
return +this.clone().startOf(units) < +moment(input).startOf(units);
|
1461
|
+
},
|
1462
|
+
|
1463
|
+
isSame: function (input, units) {
|
1464
|
+
units = typeof units !== 'undefined' ? units : 'millisecond';
|
1465
|
+
return +this.clone().startOf(units) === +moment(input).startOf(units);
|
1466
|
+
},
|
1467
|
+
|
1468
|
+
min: function (other) {
|
1469
|
+
other = moment.apply(null, arguments);
|
1470
|
+
return other < this ? this : other;
|
1471
|
+
},
|
1472
|
+
|
1473
|
+
max: function (other) {
|
1474
|
+
other = moment.apply(null, arguments);
|
1475
|
+
return other > this ? this : other;
|
1476
|
+
},
|
1477
|
+
|
1478
|
+
zone : function (input) {
|
1479
|
+
var offset = this._offset || 0;
|
1480
|
+
if (input != null) {
|
1481
|
+
if (typeof input === "string") {
|
1482
|
+
input = timezoneMinutesFromString(input);
|
1483
|
+
}
|
1484
|
+
if (Math.abs(input) < 16) {
|
1485
|
+
input = input * 60;
|
1486
|
+
}
|
1487
|
+
this._offset = input;
|
1488
|
+
this._isUTC = true;
|
1489
|
+
if (offset !== input) {
|
1490
|
+
addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true);
|
1491
|
+
}
|
1492
|
+
} else {
|
1493
|
+
return this._isUTC ? offset : this._d.getTimezoneOffset();
|
1494
|
+
}
|
1495
|
+
return this;
|
1496
|
+
},
|
1497
|
+
|
1498
|
+
zoneAbbr : function () {
|
1499
|
+
return this._isUTC ? "UTC" : "";
|
1500
|
+
},
|
1501
|
+
|
1502
|
+
zoneName : function () {
|
1503
|
+
return this._isUTC ? "Coordinated Universal Time" : "";
|
1504
|
+
},
|
1505
|
+
|
1506
|
+
hasAlignedHourOffset : function (input) {
|
1507
|
+
if (!input) {
|
1508
|
+
input = 0;
|
1509
|
+
}
|
1510
|
+
else {
|
1511
|
+
input = moment(input).zone();
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
return (this.zone() - input) % 60 === 0;
|
1515
|
+
},
|
1516
|
+
|
1517
|
+
daysInMonth : function () {
|
1518
|
+
return moment.utc([this.year(), this.month() + 1, 0]).date();
|
1519
|
+
},
|
1520
|
+
|
1521
|
+
dayOfYear : function (input) {
|
1522
|
+
var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
|
1523
|
+
return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
|
1524
|
+
},
|
1525
|
+
|
1526
|
+
weekYear : function (input) {
|
1527
|
+
var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year;
|
1528
|
+
return input == null ? year : this.add("y", (input - year));
|
1529
|
+
},
|
1530
|
+
|
1531
|
+
isoWeekYear : function (input) {
|
1532
|
+
var year = weekOfYear(this, 1, 4).year;
|
1533
|
+
return input == null ? year : this.add("y", (input - year));
|
1534
|
+
},
|
1535
|
+
|
1536
|
+
week : function (input) {
|
1537
|
+
var week = this.lang().week(this);
|
1538
|
+
return input == null ? week : this.add("d", (input - week) * 7);
|
1539
|
+
},
|
1540
|
+
|
1541
|
+
isoWeek : function (input) {
|
1542
|
+
var week = weekOfYear(this, 1, 4).week;
|
1543
|
+
return input == null ? week : this.add("d", (input - week) * 7);
|
1544
|
+
},
|
1545
|
+
|
1546
|
+
weekday : function (input) {
|
1547
|
+
var weekday = (this._d.getDay() + 7 - this.lang()._week.dow) % 7;
|
1548
|
+
return input == null ? weekday : this.add("d", input - weekday);
|
1549
|
+
},
|
1550
|
+
|
1551
|
+
isoWeekday : function (input) {
|
1552
|
+
// behaves the same as moment#day except
|
1553
|
+
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
|
1554
|
+
// as a setter, sunday should belong to the previous week.
|
1555
|
+
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
1556
|
+
},
|
1557
|
+
|
1558
|
+
get : function (units) {
|
1559
|
+
units = normalizeUnits(units);
|
1560
|
+
return this[units.toLowerCase()]();
|
1561
|
+
},
|
1562
|
+
|
1563
|
+
set : function (units, value) {
|
1564
|
+
units = normalizeUnits(units);
|
1565
|
+
this[units.toLowerCase()](value);
|
1566
|
+
},
|
1567
|
+
|
1568
|
+
// If passed a language key, it will set the language for this
|
1569
|
+
// instance. Otherwise, it will return the language configuration
|
1570
|
+
// variables for this instance.
|
1571
|
+
lang : function (key) {
|
1572
|
+
if (key === undefined) {
|
1573
|
+
return this._lang;
|
1574
|
+
} else {
|
1575
|
+
this._lang = getLangDefinition(key);
|
1576
|
+
return this;
|
1577
|
+
}
|
1578
|
+
}
|
1579
|
+
});
|
1580
|
+
|
1581
|
+
// helper for adding shortcuts
|
1582
|
+
function makeGetterAndSetter(name, key) {
|
1583
|
+
moment.fn[name] = moment.fn[name + 's'] = function (input) {
|
1584
|
+
var utc = this._isUTC ? 'UTC' : '';
|
1585
|
+
if (input != null) {
|
1586
|
+
this._d['set' + utc + key](input);
|
1587
|
+
moment.updateOffset(this);
|
1588
|
+
return this;
|
1589
|
+
} else {
|
1590
|
+
return this._d['get' + utc + key]();
|
1591
|
+
}
|
1592
|
+
};
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
// loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds, Milliseconds)
|
1596
|
+
for (i = 0; i < proxyGettersAndSetters.length; i ++) {
|
1597
|
+
makeGetterAndSetter(proxyGettersAndSetters[i].toLowerCase().replace(/s$/, ''), proxyGettersAndSetters[i]);
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
// add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear')
|
1601
|
+
makeGetterAndSetter('year', 'FullYear');
|
1602
|
+
|
1603
|
+
// add plural methods
|
1604
|
+
moment.fn.days = moment.fn.day;
|
1605
|
+
moment.fn.months = moment.fn.month;
|
1606
|
+
moment.fn.weeks = moment.fn.week;
|
1607
|
+
moment.fn.isoWeeks = moment.fn.isoWeek;
|
1608
|
+
|
1609
|
+
// add aliased format methods
|
1610
|
+
moment.fn.toJSON = moment.fn.toISOString;
|
1611
|
+
|
1612
|
+
/************************************
|
1613
|
+
Duration Prototype
|
1614
|
+
************************************/
|
1615
|
+
|
1616
|
+
|
1617
|
+
extend(moment.duration.fn = Duration.prototype, {
|
1618
|
+
|
1619
|
+
_bubble : function () {
|
1620
|
+
var milliseconds = this._milliseconds,
|
1621
|
+
days = this._days,
|
1622
|
+
months = this._months,
|
1623
|
+
data = this._data,
|
1624
|
+
seconds, minutes, hours, years;
|
1625
|
+
|
1626
|
+
// The following code bubbles up values, see the tests for
|
1627
|
+
// examples of what that means.
|
1628
|
+
data.milliseconds = milliseconds % 1000;
|
1629
|
+
|
1630
|
+
seconds = absRound(milliseconds / 1000);
|
1631
|
+
data.seconds = seconds % 60;
|
1632
|
+
|
1633
|
+
minutes = absRound(seconds / 60);
|
1634
|
+
data.minutes = minutes % 60;
|
1635
|
+
|
1636
|
+
hours = absRound(minutes / 60);
|
1637
|
+
data.hours = hours % 24;
|
1638
|
+
|
1639
|
+
days += absRound(hours / 24);
|
1640
|
+
data.days = days % 30;
|
1641
|
+
|
1642
|
+
months += absRound(days / 30);
|
1643
|
+
data.months = months % 12;
|
1644
|
+
|
1645
|
+
years = absRound(months / 12);
|
1646
|
+
data.years = years;
|
1647
|
+
},
|
1648
|
+
|
1649
|
+
weeks : function () {
|
1650
|
+
return absRound(this.days() / 7);
|
1651
|
+
},
|
1652
|
+
|
1653
|
+
valueOf : function () {
|
1654
|
+
return this._milliseconds +
|
1655
|
+
this._days * 864e5 +
|
1656
|
+
(this._months % 12) * 2592e6 +
|
1657
|
+
~~(this._months / 12) * 31536e6;
|
1658
|
+
},
|
1659
|
+
|
1660
|
+
humanize : function (withSuffix) {
|
1661
|
+
var difference = +this,
|
1662
|
+
output = relativeTime(difference, !withSuffix, this.lang());
|
1663
|
+
|
1664
|
+
if (withSuffix) {
|
1665
|
+
output = this.lang().pastFuture(difference, output);
|
1666
|
+
}
|
1667
|
+
|
1668
|
+
return this.lang().postformat(output);
|
1669
|
+
},
|
1670
|
+
|
1671
|
+
add : function (input, val) {
|
1672
|
+
// supports only 2.0-style add(1, 's') or add(moment)
|
1673
|
+
var dur = moment.duration(input, val);
|
1674
|
+
|
1675
|
+
this._milliseconds += dur._milliseconds;
|
1676
|
+
this._days += dur._days;
|
1677
|
+
this._months += dur._months;
|
1678
|
+
|
1679
|
+
this._bubble();
|
1680
|
+
|
1681
|
+
return this;
|
1682
|
+
},
|
1683
|
+
|
1684
|
+
subtract : function (input, val) {
|
1685
|
+
var dur = moment.duration(input, val);
|
1686
|
+
|
1687
|
+
this._milliseconds -= dur._milliseconds;
|
1688
|
+
this._days -= dur._days;
|
1689
|
+
this._months -= dur._months;
|
1690
|
+
|
1691
|
+
this._bubble();
|
1692
|
+
|
1693
|
+
return this;
|
1694
|
+
},
|
1695
|
+
|
1696
|
+
get : function (units) {
|
1697
|
+
units = normalizeUnits(units);
|
1698
|
+
return this[units.toLowerCase() + 's']();
|
1699
|
+
},
|
1700
|
+
|
1701
|
+
as : function (units) {
|
1702
|
+
units = normalizeUnits(units);
|
1703
|
+
return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's']();
|
1704
|
+
},
|
1705
|
+
|
1706
|
+
lang : moment.fn.lang
|
1707
|
+
});
|
1708
|
+
|
1709
|
+
function makeDurationGetter(name) {
|
1710
|
+
moment.duration.fn[name] = function () {
|
1711
|
+
return this._data[name];
|
1712
|
+
};
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
function makeDurationAsGetter(name, factor) {
|
1716
|
+
moment.duration.fn['as' + name] = function () {
|
1717
|
+
return +this / factor;
|
1718
|
+
};
|
1719
|
+
}
|
1720
|
+
|
1721
|
+
for (i in unitMillisecondFactors) {
|
1722
|
+
if (unitMillisecondFactors.hasOwnProperty(i)) {
|
1723
|
+
makeDurationAsGetter(i, unitMillisecondFactors[i]);
|
1724
|
+
makeDurationGetter(i.toLowerCase());
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
makeDurationAsGetter('Weeks', 6048e5);
|
1729
|
+
moment.duration.fn.asMonths = function () {
|
1730
|
+
return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12;
|
1731
|
+
};
|
1732
|
+
|
1733
|
+
|
1734
|
+
/************************************
|
1735
|
+
Default Lang
|
1736
|
+
************************************/
|
1737
|
+
|
1738
|
+
|
1739
|
+
// Set default language, other languages will inherit from English.
|
1740
|
+
moment.lang('en', {
|
1741
|
+
ordinal : function (number) {
|
1742
|
+
var b = number % 10,
|
1743
|
+
output = (~~ (number % 100 / 10) === 1) ? 'th' :
|
1744
|
+
(b === 1) ? 'st' :
|
1745
|
+
(b === 2) ? 'nd' :
|
1746
|
+
(b === 3) ? 'rd' : 'th';
|
1747
|
+
return number + output;
|
1748
|
+
}
|
1749
|
+
});
|
1750
|
+
|
1751
|
+
// moment.js language configuration
|
1752
|
+
|
1753
|
+
// moment.js language configuration
|
1754
|
+
// language : german (de)
|
1755
|
+
// author : lluchs : https://github.com/lluchs
|
1756
|
+
// author: Menelion Elensúle: https://github.com/Oire
|
1757
|
+
|
1758
|
+
(function (factory) {
|
1759
|
+
factory(moment);
|
1760
|
+
}(function (moment) {
|
1761
|
+
function processRelativeTime(number, withoutSuffix, key, isFuture) {
|
1762
|
+
var format = {
|
1763
|
+
'm': ['eine Minute', 'einer Minute'],
|
1764
|
+
'h': ['eine Stunde', 'einer Stunde'],
|
1765
|
+
'd': ['ein Tag', 'einem Tag'],
|
1766
|
+
'dd': [number + ' Tage', number + ' Tagen'],
|
1767
|
+
'M': ['ein Monat', 'einem Monat'],
|
1768
|
+
'MM': [number + ' Monate', number + ' Monaten'],
|
1769
|
+
'y': ['ein Jahr', 'einem Jahr'],
|
1770
|
+
'yy': [number + ' Jahre', number + ' Jahren']
|
1771
|
+
};
|
1772
|
+
return withoutSuffix ? format[key][0] : format[key][1];
|
1773
|
+
}
|
1774
|
+
|
1775
|
+
moment.lang('de', {
|
1776
|
+
months : "Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember".split("_"),
|
1777
|
+
monthsShort : "Jan._Febr._Mrz._Apr._Mai_Jun._Jul._Aug._Sept._Okt._Nov._Dez.".split("_"),
|
1778
|
+
weekdays : "Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag".split("_"),
|
1779
|
+
weekdaysShort : "So._Mo._Di._Mi._Do._Fr._Sa.".split("_"),
|
1780
|
+
weekdaysMin : "So_Mo_Di_Mi_Do_Fr_Sa".split("_"),
|
1781
|
+
longDateFormat : {
|
1782
|
+
LT: "H:mm [Uhr]",
|
1783
|
+
L : "DD.MM.YYYY",
|
1784
|
+
LL : "D. MMMM YYYY",
|
1785
|
+
LLL : "D. MMMM YYYY LT",
|
1786
|
+
LLLL : "dddd, D. MMMM YYYY LT"
|
1787
|
+
},
|
1788
|
+
calendar : {
|
1789
|
+
sameDay: "[Heute um] LT",
|
1790
|
+
sameElse: "L",
|
1791
|
+
nextDay: '[Morgen um] LT',
|
1792
|
+
nextWeek: 'dddd [um] LT',
|
1793
|
+
lastDay: '[Gestern um] LT',
|
1794
|
+
lastWeek: '[letzten] dddd [um] LT'
|
1795
|
+
},
|
1796
|
+
relativeTime : {
|
1797
|
+
future : "in %s",
|
1798
|
+
past : "vor %s",
|
1799
|
+
s : "ein paar Sekunden",
|
1800
|
+
m : processRelativeTime,
|
1801
|
+
mm : "%d Minuten",
|
1802
|
+
h : processRelativeTime,
|
1803
|
+
hh : "%d Stunden",
|
1804
|
+
d : processRelativeTime,
|
1805
|
+
dd : processRelativeTime,
|
1806
|
+
M : processRelativeTime,
|
1807
|
+
MM : processRelativeTime,
|
1808
|
+
y : processRelativeTime,
|
1809
|
+
yy : processRelativeTime
|
1810
|
+
},
|
1811
|
+
ordinal : '%d.',
|
1812
|
+
week : {
|
1813
|
+
dow : 1, // Monday is the first day of the week.
|
1814
|
+
doy : 4 // The week that contains Jan 4th is the first week of the year.
|
1815
|
+
}
|
1816
|
+
});
|
1817
|
+
}));
|
1818
|
+
|
1819
|
+
// moment.js language configuration
|
1820
|
+
// language : great britain english (en-gb)
|
1821
|
+
// author : Chris Gedrim : https://github.com/chrisgedrim
|
1822
|
+
|
1823
|
+
(function (factory) {
|
1824
|
+
factory(moment);
|
1825
|
+
}(function (moment) {
|
1826
|
+
moment.lang('en-gb', {
|
1827
|
+
months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
1828
|
+
monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
|
1829
|
+
weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
1830
|
+
weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
|
1831
|
+
weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
|
1832
|
+
longDateFormat : {
|
1833
|
+
LT : "HH:mm",
|
1834
|
+
L : "DD/MM/YYYY",
|
1835
|
+
LL : "D MMMM YYYY",
|
1836
|
+
LLL : "D MMMM YYYY LT",
|
1837
|
+
LLLL : "dddd, D MMMM YYYY LT"
|
1838
|
+
},
|
1839
|
+
calendar : {
|
1840
|
+
sameDay : '[Today at] LT',
|
1841
|
+
nextDay : '[Tomorrow at] LT',
|
1842
|
+
nextWeek : 'dddd [at] LT',
|
1843
|
+
lastDay : '[Yesterday at] LT',
|
1844
|
+
lastWeek : '[Last] dddd [at] LT',
|
1845
|
+
sameElse : 'L'
|
1846
|
+
},
|
1847
|
+
relativeTime : {
|
1848
|
+
future : "in %s",
|
1849
|
+
past : "%s ago",
|
1850
|
+
s : "a few seconds",
|
1851
|
+
m : "a minute",
|
1852
|
+
mm : "%d minutes",
|
1853
|
+
h : "an hour",
|
1854
|
+
hh : "%d hours",
|
1855
|
+
d : "a day",
|
1856
|
+
dd : "%d days",
|
1857
|
+
M : "a month",
|
1858
|
+
MM : "%d months",
|
1859
|
+
y : "a year",
|
1860
|
+
yy : "%d years"
|
1861
|
+
},
|
1862
|
+
ordinal : function (number) {
|
1863
|
+
var b = number % 10,
|
1864
|
+
output = (~~ (number % 100 / 10) === 1) ? 'th' :
|
1865
|
+
(b === 1) ? 'st' :
|
1866
|
+
(b === 2) ? 'nd' :
|
1867
|
+
(b === 3) ? 'rd' : 'th';
|
1868
|
+
return number + output;
|
1869
|
+
},
|
1870
|
+
week : {
|
1871
|
+
dow : 1, // Monday is the first day of the week.
|
1872
|
+
doy : 4 // The week that contains Jan 4th is the first week of the year.
|
1873
|
+
}
|
1874
|
+
});
|
1875
|
+
}));
|
1876
|
+
|
1877
|
+
moment.lang('en');
|
1878
|
+
|
1879
|
+
|
1880
|
+
/************************************
|
1881
|
+
Exposing Moment
|
1882
|
+
************************************/
|
1883
|
+
|
1884
|
+
|
1885
|
+
// CommonJS module is defined
|
1886
|
+
if (hasModule) {
|
1887
|
+
module.exports = moment;
|
1888
|
+
}
|
1889
|
+
/*global ender:false */
|
1890
|
+
if (typeof ender === 'undefined') {
|
1891
|
+
// here, `this` means `window` in the browser, or `global` on the server
|
1892
|
+
// add `moment` as a global object via a string identifier,
|
1893
|
+
// for Closure Compiler "advanced" mode
|
1894
|
+
this['moment'] = moment;
|
1895
|
+
}
|
1896
|
+
/*global define:false */
|
1897
|
+
if (typeof define === "function" && define.amd) {
|
1898
|
+
define("moment", [], function () {
|
1899
|
+
return moment;
|
1900
|
+
});
|
1901
|
+
}
|
1902
|
+
}).call(this);
|