bootstrap-daterangepicker-rails 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,6 +40,13 @@
40
40
  display: none;
41
41
  max-width: 250px;
42
42
  }
43
+ .daterangepicker.show-calendar .calendar {
44
+ display: block;
45
+ }
46
+
47
+ .daterangepicker .calendar.single .calendar-date {
48
+ border: none;
49
+ }
43
50
 
44
51
  .daterangepicker .calendar th, .daterangepicker .calendar td {
45
52
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
@@ -47,7 +54,8 @@
47
54
  text-align: center;
48
55
  }
49
56
 
50
- .daterangepicker .ranges label {
57
+ .daterangepicker .daterangepicker_start_input label,
58
+ .daterangepicker .daterangepicker_end_input label {
51
59
  color: #333;
52
60
  font-size: 11px;
53
61
  margin-bottom: 2px;
@@ -233,3 +241,16 @@
233
241
  width: 60px;
234
242
  margin-bottom: 0;
235
243
  }
244
+
245
+ .daterangepicker_start_input {
246
+ float: left;
247
+ }
248
+
249
+ .daterangepicker_end_input {
250
+ float: left;
251
+ padding-left: 11px
252
+ }
253
+
254
+ .daterangepicker th.month {
255
+ width: auto;
256
+ }
@@ -41,6 +41,14 @@
41
41
  max-width: 270px;
42
42
  }
43
43
 
44
+ .daterangepicker.show-calendar .calendar {
45
+ display: block;
46
+ }
47
+
48
+ .daterangepicker .calendar.single .calendar-date {
49
+ border: none;
50
+ }
51
+
44
52
  .daterangepicker .calendar th, .daterangepicker .calendar td {
45
53
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
46
54
  white-space: nowrap;
@@ -48,7 +56,8 @@
48
56
  min-width: 32px;
49
57
  }
50
58
 
51
- .daterangepicker .ranges label {
59
+ .daterangepicker .daterangepicker_start_input label,
60
+ .daterangepicker .daterangepicker_end_input label {
52
61
  color: #333;
53
62
  display: block;
54
63
  font-size: 11px;
@@ -80,6 +89,10 @@
80
89
  width: 74px;
81
90
  }
82
91
 
92
+ .daterangepicker .ranges .input-mini:hover {
93
+ cursor: pointer;
94
+ }
95
+
83
96
  .daterangepicker .ranges ul {
84
97
  list-style: none;
85
98
  margin: 0;
@@ -211,6 +224,24 @@
211
224
  border-radius: 0;
212
225
  }
213
226
 
227
+ .daterangepicker td.available + td.start-date {
228
+ -webkit-border-radius: 4px 0 0 4px;
229
+ -moz-border-radius: 4px 0 0 4px;
230
+ border-radius: 4px 0 0 4px;
231
+ }
232
+
233
+ .daterangepicker td.in-range + td.end-date{
234
+ -webkit-border-radius: 0 4px 4px 0;
235
+ -moz-border-radius: 0 4px 4px 0;
236
+ border-radius: 0 4px 4px 0;
237
+ }
238
+
239
+ .daterangepicker td.start-date.end-date{
240
+ -webkit-border-radius: 4px !important;
241
+ -moz-border-radius: 4px !important;
242
+ border-radius: 4px !important;
243
+ }
244
+
214
245
  .daterangepicker td.active, .daterangepicker td.active:hover {
215
246
  background-color: #357ebd;
216
247
  border-color: #3071a9;
@@ -243,3 +274,16 @@
243
274
  width: 50px;
244
275
  margin-bottom: 0;
245
276
  }
277
+
278
+ .daterangepicker_start_input {
279
+ float: left;
280
+ }
281
+
282
+ .daterangepicker_end_input {
283
+ float: left;
284
+ padding-left: 11px
285
+ }
286
+
287
+ .daterangepicker th.month {
288
+ width: auto;
289
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-daterangepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Grossman
@@ -9,54 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-02 00:00:00.000000000 Z
12
+ date: 2014-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '3.1'
20
+ version: '4.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '3.1'
27
+ version: '4.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: test-unit
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 2.2.0
34
+ version: '2.2'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 2.2.0
42
- description: Rails 3.2.x plugin to allow for the easy use of Dan Grossman's Bootstrap
41
+ version: '2.2'
42
+ description: Rails 4.1.x plugin to allow for the easy use of Dan Grossman's Bootstrap
43
43
  DateRangePicker
44
44
  email: jordan@brock.id.au
45
45
  executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - lib/bootstrap-daterangepicker-rails.rb
49
53
  - lib/bootstrap-daterangepicker-rails/helpers/input_helper.rb
50
54
  - lib/bootstrap-daterangepicker-rails/version.rb
51
- - lib/bootstrap-daterangepicker-rails.rb
52
55
  - vendor/assets/javascripts/daterangepicker.js
53
- - vendor/assets/javascripts/moment.js
54
- - vendor/assets/javascripts/moment.min.js
55
56
  - vendor/assets/stylesheets/daterangepicker-bs2.css
56
57
  - vendor/assets/stylesheets/daterangepicker-bs3.css
57
- - LICENSE
58
- - README.md
59
- - Rakefile
60
58
  homepage: http://github.com/jordanbrock/bootstrap-daterangepicker-rails
61
59
  licenses: []
62
60
  metadata: {}
@@ -66,19 +64,18 @@ require_paths:
66
64
  - lib
67
65
  required_ruby_version: !ruby/object:Gem::Requirement
68
66
  requirements:
69
- - - '>='
67
+ - - ">="
70
68
  - !ruby/object:Gem::Version
71
69
  version: '0'
72
70
  required_rubygems_version: !ruby/object:Gem::Requirement
73
71
  requirements:
74
- - - '>='
72
+ - - ">="
75
73
  - !ruby/object:Gem::Version
76
74
  version: '0'
77
75
  requirements: []
78
76
  rubyforge_project:
79
- rubygems_version: 2.1.11
77
+ rubygems_version: 2.3.0
80
78
  signing_key:
81
79
  specification_version: 4
82
- summary: Rails 3.2.x plugin to allow for the easy use of Dan Grossman's Bootstrap
83
- DateRangePicker
80
+ summary: Rails 4.1x plugin to allow for the easy use of Dan Grossman's Bootstrap DateRangePicker
84
81
  test_files: []
@@ -1,1662 +0,0 @@
1
- // moment.js
2
- // version : 2.1.0
3
- // author : Tim Wood
4
- // license : MIT
5
- // momentjs.com
6
-
7
- (function (undefined) {
8
-
9
- /************************************
10
- Constants
11
- ************************************/
12
-
13
- var moment,
14
- VERSION = "2.1.0",
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
- M : 'month',
77
- y : 'year'
78
- },
79
-
80
- // format function strings
81
- formatFunctions = {},
82
-
83
- // tokens to ordinalize and pad
84
- ordinalizeTokens = 'DDD w W M D d'.split(' '),
85
- paddedTokens = 'M D H h m s w W'.split(' '),
86
-
87
- formatTokenFunctions = {
88
- M : function () {
89
- return this.month() + 1;
90
- },
91
- MMM : function (format) {
92
- return this.lang().monthsShort(this, format);
93
- },
94
- MMMM : function (format) {
95
- return this.lang().months(this, format);
96
- },
97
- D : function () {
98
- return this.date();
99
- },
100
- DDD : function () {
101
- return this.dayOfYear();
102
- },
103
- d : function () {
104
- return this.day();
105
- },
106
- dd : function (format) {
107
- return this.lang().weekdaysMin(this, format);
108
- },
109
- ddd : function (format) {
110
- return this.lang().weekdaysShort(this, format);
111
- },
112
- dddd : function (format) {
113
- return this.lang().weekdays(this, format);
114
- },
115
- w : function () {
116
- return this.week();
117
- },
118
- W : function () {
119
- return this.isoWeek();
120
- },
121
- YY : function () {
122
- return leftZeroFill(this.year() % 100, 2);
123
- },
124
- YYYY : function () {
125
- return leftZeroFill(this.year(), 4);
126
- },
127
- YYYYY : function () {
128
- return leftZeroFill(this.year(), 5);
129
- },
130
- gg : function () {
131
- return leftZeroFill(this.weekYear() % 100, 2);
132
- },
133
- gggg : function () {
134
- return this.weekYear();
135
- },
136
- ggggg : function () {
137
- return leftZeroFill(this.weekYear(), 5);
138
- },
139
- GG : function () {
140
- return leftZeroFill(this.isoWeekYear() % 100, 2);
141
- },
142
- GGGG : function () {
143
- return this.isoWeekYear();
144
- },
145
- GGGGG : function () {
146
- return leftZeroFill(this.isoWeekYear(), 5);
147
- },
148
- e : function () {
149
- return this.weekday();
150
- },
151
- E : function () {
152
- return this.isoWeekday();
153
- },
154
- a : function () {
155
- return this.lang().meridiem(this.hours(), this.minutes(), true);
156
- },
157
- A : function () {
158
- return this.lang().meridiem(this.hours(), this.minutes(), false);
159
- },
160
- H : function () {
161
- return this.hours();
162
- },
163
- h : function () {
164
- return this.hours() % 12 || 12;
165
- },
166
- m : function () {
167
- return this.minutes();
168
- },
169
- s : function () {
170
- return this.seconds();
171
- },
172
- S : function () {
173
- return ~~(this.milliseconds() / 100);
174
- },
175
- SS : function () {
176
- return leftZeroFill(~~(this.milliseconds() / 10), 2);
177
- },
178
- SSS : function () {
179
- return leftZeroFill(this.milliseconds(), 3);
180
- },
181
- Z : function () {
182
- var a = -this.zone(),
183
- b = "+";
184
- if (a < 0) {
185
- a = -a;
186
- b = "-";
187
- }
188
- return b + leftZeroFill(~~(a / 60), 2) + ":" + leftZeroFill(~~a % 60, 2);
189
- },
190
- ZZ : function () {
191
- var a = -this.zone(),
192
- b = "+";
193
- if (a < 0) {
194
- a = -a;
195
- b = "-";
196
- }
197
- return b + leftZeroFill(~~(10 * a / 6), 4);
198
- },
199
- z : function () {
200
- return this.zoneAbbr();
201
- },
202
- zz : function () {
203
- return this.zoneName();
204
- },
205
- X : function () {
206
- return this.unix();
207
- }
208
- };
209
-
210
- function padToken(func, count) {
211
- return function (a) {
212
- return leftZeroFill(func.call(this, a), count);
213
- };
214
- }
215
- function ordinalizeToken(func, period) {
216
- return function (a) {
217
- return this.lang().ordinal(func.call(this, a), period);
218
- };
219
- }
220
-
221
- while (ordinalizeTokens.length) {
222
- i = ordinalizeTokens.pop();
223
- formatTokenFunctions[i + 'o'] = ordinalizeToken(formatTokenFunctions[i], i);
224
- }
225
- while (paddedTokens.length) {
226
- i = paddedTokens.pop();
227
- formatTokenFunctions[i + i] = padToken(formatTokenFunctions[i], 2);
228
- }
229
- formatTokenFunctions.DDDD = padToken(formatTokenFunctions.DDD, 3);
230
-
231
-
232
- /************************************
233
- Constructors
234
- ************************************/
235
-
236
- function Language() {
237
-
238
- }
239
-
240
- // Moment prototype object
241
- function Moment(config) {
242
- extend(this, config);
243
- }
244
-
245
- // Duration Constructor
246
- function Duration(duration) {
247
- var years = duration.years || duration.year || duration.y || 0,
248
- months = duration.months || duration.month || duration.M || 0,
249
- weeks = duration.weeks || duration.week || duration.w || 0,
250
- days = duration.days || duration.day || duration.d || 0,
251
- hours = duration.hours || duration.hour || duration.h || 0,
252
- minutes = duration.minutes || duration.minute || duration.m || 0,
253
- seconds = duration.seconds || duration.second || duration.s || 0,
254
- milliseconds = duration.milliseconds || duration.millisecond || duration.ms || 0;
255
-
256
- // store reference to input for deterministic cloning
257
- this._input = duration;
258
-
259
- // representation for dateAddRemove
260
- this._milliseconds = milliseconds +
261
- seconds * 1e3 + // 1000
262
- minutes * 6e4 + // 1000 * 60
263
- hours * 36e5; // 1000 * 60 * 60
264
- // Because of dateAddRemove treats 24 hours as different from a
265
- // day when working around DST, we need to store them separately
266
- this._days = days +
267
- weeks * 7;
268
- // It is impossible translate months into days without knowing
269
- // which months you are are talking about, so we have to store
270
- // it separately.
271
- this._months = months +
272
- years * 12;
273
-
274
- this._data = {};
275
-
276
- this._bubble();
277
- }
278
-
279
-
280
- /************************************
281
- Helpers
282
- ************************************/
283
-
284
-
285
- function extend(a, b) {
286
- for (var i in b) {
287
- if (b.hasOwnProperty(i)) {
288
- a[i] = b[i];
289
- }
290
- }
291
- return a;
292
- }
293
-
294
- function absRound(number) {
295
- if (number < 0) {
296
- return Math.ceil(number);
297
- } else {
298
- return Math.floor(number);
299
- }
300
- }
301
-
302
- // left zero fill a number
303
- // see http://jsperf.com/left-zero-filling for performance comparison
304
- function leftZeroFill(number, targetLength) {
305
- var output = number + '';
306
- while (output.length < targetLength) {
307
- output = '0' + output;
308
- }
309
- return output;
310
- }
311
-
312
- // helper function for _.addTime and _.subtractTime
313
- function addOrSubtractDurationFromMoment(mom, duration, isAdding, ignoreUpdateOffset) {
314
- var milliseconds = duration._milliseconds,
315
- days = duration._days,
316
- months = duration._months,
317
- minutes,
318
- hours,
319
- currentDate;
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
- Language.prototype = {
375
- set : function (config) {
376
- var prop, i;
377
- for (i in config) {
378
- prop = config[i];
379
- if (typeof prop === 'function') {
380
- this[i] = prop;
381
- } else {
382
- this['_' + i] = prop;
383
- }
384
- }
385
- },
386
-
387
- _months : "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
388
- months : function (m) {
389
- return this._months[m.month()];
390
- },
391
-
392
- _monthsShort : "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
393
- monthsShort : function (m) {
394
- return this._monthsShort[m.month()];
395
- },
396
-
397
- monthsParse : function (monthName) {
398
- var i, mom, regex;
399
-
400
- if (!this._monthsParse) {
401
- this._monthsParse = [];
402
- }
403
-
404
- for (i = 0; i < 12; i++) {
405
- // make the regex if we don't have it already
406
- if (!this._monthsParse[i]) {
407
- mom = moment([2000, i]);
408
- regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
409
- this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
410
- }
411
- // test the regex
412
- if (this._monthsParse[i].test(monthName)) {
413
- return i;
414
- }
415
- }
416
- },
417
-
418
- _weekdays : "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
419
- weekdays : function (m) {
420
- return this._weekdays[m.day()];
421
- },
422
-
423
- _weekdaysShort : "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
424
- weekdaysShort : function (m) {
425
- return this._weekdaysShort[m.day()];
426
- },
427
-
428
- _weekdaysMin : "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
429
- weekdaysMin : function (m) {
430
- return this._weekdaysMin[m.day()];
431
- },
432
-
433
- weekdaysParse : function (weekdayName) {
434
- var i, mom, regex;
435
-
436
- if (!this._weekdaysParse) {
437
- this._weekdaysParse = [];
438
- }
439
-
440
- for (i = 0; i < 7; i++) {
441
- // make the regex if we don't have it already
442
- if (!this._weekdaysParse[i]) {
443
- mom = moment([2000, 1]).day(i);
444
- regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
445
- this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
446
- }
447
- // test the regex
448
- if (this._weekdaysParse[i].test(weekdayName)) {
449
- return i;
450
- }
451
- }
452
- },
453
-
454
- _longDateFormat : {
455
- LT : "h:mm A",
456
- L : "MM/DD/YYYY",
457
- LL : "MMMM D YYYY",
458
- LLL : "MMMM D YYYY LT",
459
- LLLL : "dddd, MMMM D YYYY LT"
460
- },
461
- longDateFormat : function (key) {
462
- var output = this._longDateFormat[key];
463
- if (!output && this._longDateFormat[key.toUpperCase()]) {
464
- output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
465
- return val.slice(1);
466
- });
467
- this._longDateFormat[key] = output;
468
- }
469
- return output;
470
- },
471
-
472
- isPM : function (input) {
473
- return ((input + '').toLowerCase()[0] === 'p');
474
- },
475
-
476
- _meridiemParse : /[ap]\.?m?\.?/i,
477
- meridiem : function (hours, minutes, isLower) {
478
- if (hours > 11) {
479
- return isLower ? 'pm' : 'PM';
480
- } else {
481
- return isLower ? 'am' : 'AM';
482
- }
483
- },
484
-
485
- _calendar : {
486
- sameDay : '[Today at] LT',
487
- nextDay : '[Tomorrow at] LT',
488
- nextWeek : 'dddd [at] LT',
489
- lastDay : '[Yesterday at] LT',
490
- lastWeek : '[Last] dddd [at] LT',
491
- sameElse : 'L'
492
- },
493
- calendar : function (key, mom) {
494
- var output = this._calendar[key];
495
- return typeof output === 'function' ? output.apply(mom) : output;
496
- },
497
-
498
- _relativeTime : {
499
- future : "in %s",
500
- past : "%s ago",
501
- s : "a few seconds",
502
- m : "a minute",
503
- mm : "%d minutes",
504
- h : "an hour",
505
- hh : "%d hours",
506
- d : "a day",
507
- dd : "%d days",
508
- M : "a month",
509
- MM : "%d months",
510
- y : "a year",
511
- yy : "%d years"
512
- },
513
- relativeTime : function (number, withoutSuffix, string, isFuture) {
514
- var output = this._relativeTime[string];
515
- return (typeof output === 'function') ?
516
- output(number, withoutSuffix, string, isFuture) :
517
- output.replace(/%d/i, number);
518
- },
519
- pastFuture : function (diff, output) {
520
- var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
521
- return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
522
- },
523
-
524
- ordinal : function (number) {
525
- return this._ordinal.replace("%d", number);
526
- },
527
- _ordinal : "%d",
528
-
529
- preparse : function (string) {
530
- return string;
531
- },
532
-
533
- postformat : function (string) {
534
- return string;
535
- },
536
-
537
- week : function (mom) {
538
- return weekOfYear(mom, this._week.dow, this._week.doy).week;
539
- },
540
- _week : {
541
- dow : 0, // Sunday is the first day of the week.
542
- doy : 6 // The week that contains Jan 1st is the first week of the year.
543
- }
544
- };
545
-
546
- // Loads a language definition into the `languages` cache. The function
547
- // takes a key and optionally values. If not in the browser and no values
548
- // are provided, it will load the language file module. As a convenience,
549
- // this function also returns the language values.
550
- function loadLang(key, values) {
551
- values.abbr = key;
552
- if (!languages[key]) {
553
- languages[key] = new Language();
554
- }
555
- languages[key].set(values);
556
- return languages[key];
557
- }
558
-
559
- // Determines which language definition to use and returns it.
560
- //
561
- // With no parameters, it will return the global language. If you
562
- // pass in a language key, such as 'en', it will return the
563
- // definition for 'en', so long as 'en' has already been loaded using
564
- // moment.lang.
565
- function getLangDefinition(key) {
566
- if (!key) {
567
- return moment.fn._lang;
568
- }
569
- if (!languages[key] && hasModule) {
570
- try {
571
- require('./lang/' + key);
572
- } catch (e) {
573
- // call with no params to set to default
574
- return moment.fn._lang;
575
- }
576
- }
577
- return languages[key];
578
- }
579
-
580
-
581
- /************************************
582
- Formatting
583
- ************************************/
584
-
585
-
586
- function removeFormattingTokens(input) {
587
- if (input.match(/\[.*\]/)) {
588
- return input.replace(/^\[|\]$/g, "");
589
- }
590
- return input.replace(/\\/g, "");
591
- }
592
-
593
- function makeFormatFunction(format) {
594
- var array = format.match(formattingTokens), i, length;
595
-
596
- for (i = 0, length = array.length; i < length; i++) {
597
- if (formatTokenFunctions[array[i]]) {
598
- array[i] = formatTokenFunctions[array[i]];
599
- } else {
600
- array[i] = removeFormattingTokens(array[i]);
601
- }
602
- }
603
-
604
- return function (mom) {
605
- var output = "";
606
- for (i = 0; i < length; i++) {
607
- output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
608
- }
609
- return output;
610
- };
611
- }
612
-
613
- // format date using native date object
614
- function formatMoment(m, format) {
615
- var i = 5;
616
-
617
- function replaceLongDateFormatTokens(input) {
618
- return m.lang().longDateFormat(input) || input;
619
- }
620
-
621
- while (i-- && localFormattingTokens.test(format)) {
622
- format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
623
- }
624
-
625
- if (!formatFunctions[format]) {
626
- formatFunctions[format] = makeFormatFunction(format);
627
- }
628
-
629
- return formatFunctions[format](m);
630
- }
631
-
632
-
633
- /************************************
634
- Parsing
635
- ************************************/
636
-
637
-
638
- // get the regex to find the next token
639
- function getParseRegexForToken(token, config) {
640
- switch (token) {
641
- case 'DDDD':
642
- return parseTokenThreeDigits;
643
- case 'YYYY':
644
- return parseTokenFourDigits;
645
- case 'YYYYY':
646
- return parseTokenSixDigits;
647
- case 'S':
648
- case 'SS':
649
- case 'SSS':
650
- case 'DDD':
651
- return parseTokenOneToThreeDigits;
652
- case 'MMM':
653
- case 'MMMM':
654
- case 'dd':
655
- case 'ddd':
656
- case 'dddd':
657
- return parseTokenWord;
658
- case 'a':
659
- case 'A':
660
- return getLangDefinition(config._l)._meridiemParse;
661
- case 'X':
662
- return parseTokenTimestampMs;
663
- case 'Z':
664
- case 'ZZ':
665
- return parseTokenTimezone;
666
- case 'T':
667
- return parseTokenT;
668
- case 'MM':
669
- case 'DD':
670
- case 'YY':
671
- case 'HH':
672
- case 'hh':
673
- case 'mm':
674
- case 'ss':
675
- case 'M':
676
- case 'D':
677
- case 'd':
678
- case 'H':
679
- case 'h':
680
- case 'm':
681
- case 's':
682
- return parseTokenOneOrTwoDigits;
683
- default :
684
- return new RegExp(token.replace('\\', ''));
685
- }
686
- }
687
-
688
- function timezoneMinutesFromString(string) {
689
- var tzchunk = (parseTokenTimezone.exec(string) || [])[0],
690
- parts = (tzchunk + '').match(parseTimezoneChunker) || ['-', 0, 0],
691
- minutes = +(parts[1] * 60) + ~~parts[2];
692
-
693
- return parts[0] === '+' ? -minutes : minutes;
694
- }
695
-
696
- // function to convert string input to date
697
- function addTimeToArrayFromToken(token, input, config) {
698
- var a, datePartArray = config._a;
699
-
700
- switch (token) {
701
- // MONTH
702
- case 'M' : // fall through to MM
703
- case 'MM' :
704
- datePartArray[1] = (input == null) ? 0 : ~~input - 1;
705
- break;
706
- case 'MMM' : // fall through to MMMM
707
- case 'MMMM' :
708
- a = getLangDefinition(config._l).monthsParse(input);
709
- // if we didn't find a month name, mark the date as invalid.
710
- if (a != null) {
711
- datePartArray[1] = a;
712
- } else {
713
- config._isValid = false;
714
- }
715
- break;
716
- // DAY OF MONTH
717
- case 'D' : // fall through to DDDD
718
- case 'DD' : // fall through to DDDD
719
- case 'DDD' : // fall through to DDDD
720
- case 'DDDD' :
721
- if (input != null) {
722
- datePartArray[2] = ~~input;
723
- }
724
- break;
725
- // YEAR
726
- case 'YY' :
727
- datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000);
728
- break;
729
- case 'YYYY' :
730
- case 'YYYYY' :
731
- datePartArray[0] = ~~input;
732
- break;
733
- // AM / PM
734
- case 'a' : // fall through to A
735
- case 'A' :
736
- config._isPm = getLangDefinition(config._l).isPM(input);
737
- break;
738
- // 24 HOUR
739
- case 'H' : // fall through to hh
740
- case 'HH' : // fall through to hh
741
- case 'h' : // fall through to hh
742
- case 'hh' :
743
- datePartArray[3] = ~~input;
744
- break;
745
- // MINUTE
746
- case 'm' : // fall through to mm
747
- case 'mm' :
748
- datePartArray[4] = ~~input;
749
- break;
750
- // SECOND
751
- case 's' : // fall through to ss
752
- case 'ss' :
753
- datePartArray[5] = ~~input;
754
- break;
755
- // MILLISECOND
756
- case 'S' :
757
- case 'SS' :
758
- case 'SSS' :
759
- datePartArray[6] = ~~ (('0.' + input) * 1000);
760
- break;
761
- // UNIX TIMESTAMP WITH MS
762
- case 'X':
763
- config._d = new Date(parseFloat(input) * 1000);
764
- break;
765
- // TIMEZONE
766
- case 'Z' : // fall through to ZZ
767
- case 'ZZ' :
768
- config._useUTC = true;
769
- config._tzm = timezoneMinutesFromString(input);
770
- break;
771
- }
772
-
773
- // if the input is null, the date is not valid
774
- if (input == null) {
775
- config._isValid = false;
776
- }
777
- }
778
-
779
- // convert an array to a date.
780
- // the array should mirror the parameters below
781
- // note: all values past the year are optional and will default to the lowest possible value.
782
- // [year, month, day , hour, minute, second, millisecond]
783
- function dateFromArray(config) {
784
- var i, date, input = [];
785
-
786
- if (config._d) {
787
- return;
788
- }
789
-
790
- for (i = 0; i < 7; i++) {
791
- config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
792
- }
793
-
794
- // add the offsets to the time to be parsed so that we can have a clean array for checking isValid
795
- input[3] += ~~((config._tzm || 0) / 60);
796
- input[4] += ~~((config._tzm || 0) % 60);
797
-
798
- date = new Date(0);
799
-
800
- if (config._useUTC) {
801
- date.setUTCFullYear(input[0], input[1], input[2]);
802
- date.setUTCHours(input[3], input[4], input[5], input[6]);
803
- } else {
804
- date.setFullYear(input[0], input[1], input[2]);
805
- date.setHours(input[3], input[4], input[5], input[6]);
806
- }
807
-
808
- config._d = date;
809
- }
810
-
811
- // date from string and format string
812
- function makeDateFromStringAndFormat(config) {
813
- // This array is used to make a Date, either with `new Date` or `Date.UTC`
814
- var tokens = config._f.match(formattingTokens),
815
- string = config._i,
816
- i, parsedInput;
817
-
818
- config._a = [];
819
-
820
- for (i = 0; i < tokens.length; i++) {
821
- parsedInput = (getParseRegexForToken(tokens[i], config).exec(string) || [])[0];
822
- if (parsedInput) {
823
- string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
824
- }
825
- // don't parse if its not a known token
826
- if (formatTokenFunctions[tokens[i]]) {
827
- addTimeToArrayFromToken(tokens[i], parsedInput, config);
828
- }
829
- }
830
-
831
- // add remaining unparsed input to the string
832
- if (string) {
833
- config._il = string;
834
- }
835
-
836
- // handle am pm
837
- if (config._isPm && config._a[3] < 12) {
838
- config._a[3] += 12;
839
- }
840
- // if is 12 am, change hours to 0
841
- if (config._isPm === false && config._a[3] === 12) {
842
- config._a[3] = 0;
843
- }
844
- // return
845
- dateFromArray(config);
846
- }
847
-
848
- // date from string and array of format strings
849
- function makeDateFromStringAndArray(config) {
850
- var tempConfig,
851
- tempMoment,
852
- bestMoment,
853
-
854
- scoreToBeat = 99,
855
- i,
856
- currentScore;
857
-
858
- for (i = 0; i < config._f.length; i++) {
859
- tempConfig = extend({}, config);
860
- tempConfig._f = config._f[i];
861
- makeDateFromStringAndFormat(tempConfig);
862
- tempMoment = new Moment(tempConfig);
863
-
864
- currentScore = compareArrays(tempConfig._a, tempMoment.toArray());
865
-
866
- // if there is any input that was not parsed
867
- // add a penalty for that format
868
- if (tempMoment._il) {
869
- currentScore += tempMoment._il.length;
870
- }
871
-
872
- if (currentScore < scoreToBeat) {
873
- scoreToBeat = currentScore;
874
- bestMoment = tempMoment;
875
- }
876
- }
877
-
878
- extend(config, bestMoment);
879
- }
880
-
881
- // date from iso format
882
- function makeDateFromString(config) {
883
- var i,
884
- string = config._i,
885
- match = isoRegex.exec(string);
886
-
887
- if (match) {
888
- // match[2] should be "T" or undefined
889
- config._f = 'YYYY-MM-DD' + (match[2] || " ");
890
- for (i = 0; i < 4; i++) {
891
- if (isoTimes[i][1].exec(string)) {
892
- config._f += isoTimes[i][0];
893
- break;
894
- }
895
- }
896
- if (parseTokenTimezone.exec(string)) {
897
- config._f += " Z";
898
- }
899
- makeDateFromStringAndFormat(config);
900
- } else {
901
- config._d = new Date(string);
902
- }
903
- }
904
-
905
- function makeDateFromInput(config) {
906
- var input = config._i,
907
- matched = aspNetJsonRegex.exec(input);
908
-
909
- if (input === undefined) {
910
- config._d = new Date();
911
- } else if (matched) {
912
- config._d = new Date(+matched[1]);
913
- } else if (typeof input === 'string') {
914
- makeDateFromString(config);
915
- } else if (isArray(input)) {
916
- config._a = input.slice(0);
917
- dateFromArray(config);
918
- } else {
919
- config._d = input instanceof Date ? new Date(+input) : new Date(input);
920
- }
921
- }
922
-
923
-
924
- /************************************
925
- Relative Time
926
- ************************************/
927
-
928
-
929
- // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
930
- function substituteTimeAgo(string, number, withoutSuffix, isFuture, lang) {
931
- return lang.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
932
- }
933
-
934
- function relativeTime(milliseconds, withoutSuffix, lang) {
935
- var seconds = round(Math.abs(milliseconds) / 1000),
936
- minutes = round(seconds / 60),
937
- hours = round(minutes / 60),
938
- days = round(hours / 24),
939
- years = round(days / 365),
940
- args = seconds < 45 && ['s', seconds] ||
941
- minutes === 1 && ['m'] ||
942
- minutes < 45 && ['mm', minutes] ||
943
- hours === 1 && ['h'] ||
944
- hours < 22 && ['hh', hours] ||
945
- days === 1 && ['d'] ||
946
- days <= 25 && ['dd', days] ||
947
- days <= 45 && ['M'] ||
948
- days < 345 && ['MM', round(days / 30)] ||
949
- years === 1 && ['y'] || ['yy', years];
950
- args[2] = withoutSuffix;
951
- args[3] = milliseconds > 0;
952
- args[4] = lang;
953
- return substituteTimeAgo.apply({}, args);
954
- }
955
-
956
-
957
- /************************************
958
- Week of Year
959
- ************************************/
960
-
961
-
962
- // firstDayOfWeek 0 = sun, 6 = sat
963
- // the day of the week that starts the week
964
- // (usually sunday or monday)
965
- // firstDayOfWeekOfYear 0 = sun, 6 = sat
966
- // the first week is the week that contains the first
967
- // of this day of the week
968
- // (eg. ISO weeks use thursday (4))
969
- function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
970
- var end = firstDayOfWeekOfYear - firstDayOfWeek,
971
- daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
972
- adjustedMoment;
973
-
974
-
975
- if (daysToDayOfWeek > end) {
976
- daysToDayOfWeek -= 7;
977
- }
978
-
979
- if (daysToDayOfWeek < end - 7) {
980
- daysToDayOfWeek += 7;
981
- }
982
-
983
- adjustedMoment = moment(mom).add('d', daysToDayOfWeek);
984
- return {
985
- week: Math.ceil(adjustedMoment.dayOfYear() / 7),
986
- year: adjustedMoment.year()
987
- };
988
- }
989
-
990
-
991
- /************************************
992
- Top Level Functions
993
- ************************************/
994
-
995
- function makeMoment(config) {
996
- var input = config._i,
997
- format = config._f;
998
-
999
- if (input === null || input === '') {
1000
- return null;
1001
- }
1002
-
1003
- if (typeof input === 'string') {
1004
- config._i = input = getLangDefinition().preparse(input);
1005
- }
1006
-
1007
- if (moment.isMoment(input)) {
1008
- config = extend({}, input);
1009
- config._d = new Date(+input._d);
1010
- } else if (format) {
1011
- if (isArray(format)) {
1012
- makeDateFromStringAndArray(config);
1013
- } else {
1014
- makeDateFromStringAndFormat(config);
1015
- }
1016
- } else {
1017
- makeDateFromInput(config);
1018
- }
1019
-
1020
- return new Moment(config);
1021
- }
1022
-
1023
- moment = function (input, format, lang) {
1024
- return makeMoment({
1025
- _i : input,
1026
- _f : format,
1027
- _l : lang,
1028
- _isUTC : false
1029
- });
1030
- };
1031
-
1032
- // creating with utc
1033
- moment.utc = function (input, format, lang) {
1034
- return makeMoment({
1035
- _useUTC : true,
1036
- _isUTC : true,
1037
- _l : lang,
1038
- _i : input,
1039
- _f : format
1040
- });
1041
- };
1042
-
1043
- // creating with unix timestamp (in seconds)
1044
- moment.unix = function (input) {
1045
- return moment(input * 1000);
1046
- };
1047
-
1048
- // duration
1049
- moment.duration = function (input, key) {
1050
- var isDuration = moment.isDuration(input),
1051
- isNumber = (typeof input === 'number'),
1052
- duration = (isDuration ? input._input : (isNumber ? {} : input)),
1053
- matched = aspNetTimeSpanJsonRegex.exec(input),
1054
- sign,
1055
- ret;
1056
-
1057
- if (isNumber) {
1058
- if (key) {
1059
- duration[key] = input;
1060
- } else {
1061
- duration.milliseconds = input;
1062
- }
1063
- } else if (matched) {
1064
- sign = (matched[1] === "-") ? -1 : 1;
1065
- duration = {
1066
- y: 0,
1067
- d: ~~matched[2] * sign,
1068
- h: ~~matched[3] * sign,
1069
- m: ~~matched[4] * sign,
1070
- s: ~~matched[5] * sign,
1071
- ms: ~~matched[6] * sign
1072
- };
1073
- }
1074
-
1075
- ret = new Duration(duration);
1076
-
1077
- if (isDuration && input.hasOwnProperty('_lang')) {
1078
- ret._lang = input._lang;
1079
- }
1080
-
1081
- return ret;
1082
- };
1083
-
1084
- // version number
1085
- moment.version = VERSION;
1086
-
1087
- // default format
1088
- moment.defaultFormat = isoFormat;
1089
-
1090
- // This function will be called whenever a moment is mutated.
1091
- // It is intended to keep the offset in sync with the timezone.
1092
- moment.updateOffset = function () {};
1093
-
1094
- // This function will load languages and then set the global language. If
1095
- // no arguments are passed in, it will simply return the current global
1096
- // language key.
1097
- moment.lang = function (key, values) {
1098
- if (!key) {
1099
- return moment.fn._lang._abbr;
1100
- }
1101
- if (values) {
1102
- loadLang(key, values);
1103
- } else if (!languages[key]) {
1104
- getLangDefinition(key);
1105
- }
1106
- moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key);
1107
- };
1108
-
1109
- // returns language data
1110
- moment.langData = function (key) {
1111
- if (key && key._lang && key._lang._abbr) {
1112
- key = key._lang._abbr;
1113
- }
1114
- return getLangDefinition(key);
1115
- };
1116
-
1117
- // compare moment object
1118
- moment.isMoment = function (obj) {
1119
- return obj instanceof Moment;
1120
- };
1121
-
1122
- // for typechecking Duration objects
1123
- moment.isDuration = function (obj) {
1124
- return obj instanceof Duration;
1125
- };
1126
-
1127
-
1128
- /************************************
1129
- Moment Prototype
1130
- ************************************/
1131
-
1132
-
1133
- moment.fn = Moment.prototype = {
1134
-
1135
- clone : function () {
1136
- return moment(this);
1137
- },
1138
-
1139
- valueOf : function () {
1140
- return +this._d + ((this._offset || 0) * 60000);
1141
- },
1142
-
1143
- unix : function () {
1144
- return Math.floor(+this / 1000);
1145
- },
1146
-
1147
- toString : function () {
1148
- return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
1149
- },
1150
-
1151
- toDate : function () {
1152
- return this._offset ? new Date(+this) : this._d;
1153
- },
1154
-
1155
- toISOString : function () {
1156
- return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
1157
- },
1158
-
1159
- toArray : function () {
1160
- var m = this;
1161
- return [
1162
- m.year(),
1163
- m.month(),
1164
- m.date(),
1165
- m.hours(),
1166
- m.minutes(),
1167
- m.seconds(),
1168
- m.milliseconds()
1169
- ];
1170
- },
1171
-
1172
- isValid : function () {
1173
- if (this._isValid == null) {
1174
- if (this._a) {
1175
- this._isValid = !compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray());
1176
- } else {
1177
- this._isValid = !isNaN(this._d.getTime());
1178
- }
1179
- }
1180
- return !!this._isValid;
1181
- },
1182
-
1183
- utc : function () {
1184
- return this.zone(0);
1185
- },
1186
-
1187
- local : function () {
1188
- this.zone(0);
1189
- this._isUTC = false;
1190
- return this;
1191
- },
1192
-
1193
- format : function (inputString) {
1194
- var output = formatMoment(this, inputString || moment.defaultFormat);
1195
- return this.lang().postformat(output);
1196
- },
1197
-
1198
- add : function (input, val) {
1199
- var dur;
1200
- // switch args to support add('s', 1) and add(1, 's')
1201
- if (typeof input === 'string') {
1202
- dur = moment.duration(+val, input);
1203
- } else {
1204
- dur = moment.duration(input, val);
1205
- }
1206
- addOrSubtractDurationFromMoment(this, dur, 1);
1207
- return this;
1208
- },
1209
-
1210
- subtract : function (input, val) {
1211
- var dur;
1212
- // switch args to support subtract('s', 1) and subtract(1, 's')
1213
- if (typeof input === 'string') {
1214
- dur = moment.duration(+val, input);
1215
- } else {
1216
- dur = moment.duration(input, val);
1217
- }
1218
- addOrSubtractDurationFromMoment(this, dur, -1);
1219
- return this;
1220
- },
1221
-
1222
- diff : function (input, units, asFloat) {
1223
- var that = this._isUTC ? moment(input).zone(this._offset || 0) : moment(input).local(),
1224
- zoneDiff = (this.zone() - that.zone()) * 6e4,
1225
- diff, output;
1226
-
1227
- units = normalizeUnits(units);
1228
-
1229
- if (units === 'year' || units === 'month') {
1230
- // average number of days in the months in the given dates
1231
- diff = (this.daysInMonth() + that.daysInMonth()) * 432e5; // 24 * 60 * 60 * 1000 / 2
1232
- // difference in months
1233
- output = ((this.year() - that.year()) * 12) + (this.month() - that.month());
1234
- // adjust by taking difference in days, average number of days
1235
- // and dst in the given months.
1236
- output += ((this - moment(this).startOf('month')) -
1237
- (that - moment(that).startOf('month'))) / diff;
1238
- // same as above but with zones, to negate all dst
1239
- output -= ((this.zone() - moment(this).startOf('month').zone()) -
1240
- (that.zone() - moment(that).startOf('month').zone())) * 6e4 / diff;
1241
- if (units === 'year') {
1242
- output = output / 12;
1243
- }
1244
- } else {
1245
- diff = (this - that);
1246
- output = units === 'second' ? diff / 1e3 : // 1000
1247
- units === 'minute' ? diff / 6e4 : // 1000 * 60
1248
- units === 'hour' ? diff / 36e5 : // 1000 * 60 * 60
1249
- units === 'day' ? (diff - zoneDiff) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
1250
- units === 'week' ? (diff - zoneDiff) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
1251
- diff;
1252
- }
1253
- return asFloat ? output : absRound(output);
1254
- },
1255
-
1256
- from : function (time, withoutSuffix) {
1257
- return moment.duration(this.diff(time)).lang(this.lang()._abbr).humanize(!withoutSuffix);
1258
- },
1259
-
1260
- fromNow : function (withoutSuffix) {
1261
- return this.from(moment(), withoutSuffix);
1262
- },
1263
-
1264
- calendar : function () {
1265
- var diff = this.diff(moment().startOf('day'), 'days', true),
1266
- format = diff < -6 ? 'sameElse' :
1267
- diff < -1 ? 'lastWeek' :
1268
- diff < 0 ? 'lastDay' :
1269
- diff < 1 ? 'sameDay' :
1270
- diff < 2 ? 'nextDay' :
1271
- diff < 7 ? 'nextWeek' : 'sameElse';
1272
- return this.format(this.lang().calendar(format, this));
1273
- },
1274
-
1275
- isLeapYear : function () {
1276
- var year = this.year();
1277
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
1278
- },
1279
-
1280
- isDST : function () {
1281
- return (this.zone() < this.clone().month(0).zone() ||
1282
- this.zone() < this.clone().month(5).zone());
1283
- },
1284
-
1285
- day : function (input) {
1286
- var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
1287
- if (input != null) {
1288
- if (typeof input === 'string') {
1289
- input = this.lang().weekdaysParse(input);
1290
- if (typeof input !== 'number') {
1291
- return this;
1292
- }
1293
- }
1294
- return this.add({ d : input - day });
1295
- } else {
1296
- return day;
1297
- }
1298
- },
1299
-
1300
- month : function (input) {
1301
- var utc = this._isUTC ? 'UTC' : '',
1302
- dayOfMonth,
1303
- daysInMonth;
1304
-
1305
- if (input != null) {
1306
- if (typeof input === 'string') {
1307
- input = this.lang().monthsParse(input);
1308
- if (typeof input !== 'number') {
1309
- return this;
1310
- }
1311
- }
1312
-
1313
- dayOfMonth = this.date();
1314
- this.date(1);
1315
- this._d['set' + utc + 'Month'](input);
1316
- this.date(Math.min(dayOfMonth, this.daysInMonth()));
1317
-
1318
- moment.updateOffset(this);
1319
- return this;
1320
- } else {
1321
- return this._d['get' + utc + 'Month']();
1322
- }
1323
- },
1324
-
1325
- startOf: function (units) {
1326
- units = normalizeUnits(units);
1327
- // the following switch intentionally omits break keywords
1328
- // to utilize falling through the cases.
1329
- switch (units) {
1330
- case 'year':
1331
- this.month(0);
1332
- /* falls through */
1333
- case 'month':
1334
- this.date(1);
1335
- /* falls through */
1336
- case 'week':
1337
- case 'day':
1338
- this.hours(0);
1339
- /* falls through */
1340
- case 'hour':
1341
- this.minutes(0);
1342
- /* falls through */
1343
- case 'minute':
1344
- this.seconds(0);
1345
- /* falls through */
1346
- case 'second':
1347
- this.milliseconds(0);
1348
- /* falls through */
1349
- }
1350
-
1351
- // weeks are a special case
1352
- if (units === 'week') {
1353
- this.weekday(0);
1354
- }
1355
-
1356
- return this;
1357
- },
1358
-
1359
- endOf: function (units) {
1360
- return this.startOf(units).add(units, 1).subtract('ms', 1);
1361
- },
1362
-
1363
- isAfter: function (input, units) {
1364
- units = typeof units !== 'undefined' ? units : 'millisecond';
1365
- return +this.clone().startOf(units) > +moment(input).startOf(units);
1366
- },
1367
-
1368
- isBefore: function (input, units) {
1369
- units = typeof units !== 'undefined' ? units : 'millisecond';
1370
- return +this.clone().startOf(units) < +moment(input).startOf(units);
1371
- },
1372
-
1373
- isSame: function (input, units) {
1374
- units = typeof units !== 'undefined' ? units : 'millisecond';
1375
- return +this.clone().startOf(units) === +moment(input).startOf(units);
1376
- },
1377
-
1378
- min: function (other) {
1379
- other = moment.apply(null, arguments);
1380
- return other < this ? this : other;
1381
- },
1382
-
1383
- max: function (other) {
1384
- other = moment.apply(null, arguments);
1385
- return other > this ? this : other;
1386
- },
1387
-
1388
- zone : function (input) {
1389
- var offset = this._offset || 0;
1390
- if (input != null) {
1391
- if (typeof input === "string") {
1392
- input = timezoneMinutesFromString(input);
1393
- }
1394
- if (Math.abs(input) < 16) {
1395
- input = input * 60;
1396
- }
1397
- this._offset = input;
1398
- this._isUTC = true;
1399
- if (offset !== input) {
1400
- addOrSubtractDurationFromMoment(this, moment.duration(offset - input, 'm'), 1, true);
1401
- }
1402
- } else {
1403
- return this._isUTC ? offset : this._d.getTimezoneOffset();
1404
- }
1405
- return this;
1406
- },
1407
-
1408
- zoneAbbr : function () {
1409
- return this._isUTC ? "UTC" : "";
1410
- },
1411
-
1412
- zoneName : function () {
1413
- return this._isUTC ? "Coordinated Universal Time" : "";
1414
- },
1415
-
1416
- daysInMonth : function () {
1417
- return moment.utc([this.year(), this.month() + 1, 0]).date();
1418
- },
1419
-
1420
- dayOfYear : function (input) {
1421
- var dayOfYear = round((moment(this).startOf('day') - moment(this).startOf('year')) / 864e5) + 1;
1422
- return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
1423
- },
1424
-
1425
- weekYear : function (input) {
1426
- var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year;
1427
- return input == null ? year : this.add("y", (input - year));
1428
- },
1429
-
1430
- isoWeekYear : function (input) {
1431
- var year = weekOfYear(this, 1, 4).year;
1432
- return input == null ? year : this.add("y", (input - year));
1433
- },
1434
-
1435
- week : function (input) {
1436
- var week = this.lang().week(this);
1437
- return input == null ? week : this.add("d", (input - week) * 7);
1438
- },
1439
-
1440
- isoWeek : function (input) {
1441
- var week = weekOfYear(this, 1, 4).week;
1442
- return input == null ? week : this.add("d", (input - week) * 7);
1443
- },
1444
-
1445
- weekday : function (input) {
1446
- var weekday = (this._d.getDay() + 7 - this.lang()._week.dow) % 7;
1447
- return input == null ? weekday : this.add("d", input - weekday);
1448
- },
1449
-
1450
- isoWeekday : function (input) {
1451
- // behaves the same as moment#day except
1452
- // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
1453
- // as a setter, sunday should belong to the previous week.
1454
- return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
1455
- },
1456
-
1457
- // If passed a language key, it will set the language for this
1458
- // instance. Otherwise, it will return the language configuration
1459
- // variables for this instance.
1460
- lang : function (key) {
1461
- if (key === undefined) {
1462
- return this._lang;
1463
- } else {
1464
- this._lang = getLangDefinition(key);
1465
- return this;
1466
- }
1467
- }
1468
- };
1469
-
1470
- // helper for adding shortcuts
1471
- function makeGetterAndSetter(name, key) {
1472
- moment.fn[name] = moment.fn[name + 's'] = function (input) {
1473
- var utc = this._isUTC ? 'UTC' : '';
1474
- if (input != null) {
1475
- this._d['set' + utc + key](input);
1476
- moment.updateOffset(this);
1477
- return this;
1478
- } else {
1479
- return this._d['get' + utc + key]();
1480
- }
1481
- };
1482
- }
1483
-
1484
- // loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds, Milliseconds)
1485
- for (i = 0; i < proxyGettersAndSetters.length; i ++) {
1486
- makeGetterAndSetter(proxyGettersAndSetters[i].toLowerCase().replace(/s$/, ''), proxyGettersAndSetters[i]);
1487
- }
1488
-
1489
- // add shortcut for year (uses different syntax than the getter/setter 'year' == 'FullYear')
1490
- makeGetterAndSetter('year', 'FullYear');
1491
-
1492
- // add plural methods
1493
- moment.fn.days = moment.fn.day;
1494
- moment.fn.months = moment.fn.month;
1495
- moment.fn.weeks = moment.fn.week;
1496
- moment.fn.isoWeeks = moment.fn.isoWeek;
1497
-
1498
- // add aliased format methods
1499
- moment.fn.toJSON = moment.fn.toISOString;
1500
-
1501
- /************************************
1502
- Duration Prototype
1503
- ************************************/
1504
-
1505
-
1506
- moment.duration.fn = Duration.prototype = {
1507
- _bubble : function () {
1508
- var milliseconds = this._milliseconds,
1509
- days = this._days,
1510
- months = this._months,
1511
- data = this._data,
1512
- seconds, minutes, hours, years;
1513
-
1514
- // The following code bubbles up values, see the tests for
1515
- // examples of what that means.
1516
- data.milliseconds = milliseconds % 1000;
1517
-
1518
- seconds = absRound(milliseconds / 1000);
1519
- data.seconds = seconds % 60;
1520
-
1521
- minutes = absRound(seconds / 60);
1522
- data.minutes = minutes % 60;
1523
-
1524
- hours = absRound(minutes / 60);
1525
- data.hours = hours % 24;
1526
-
1527
- days += absRound(hours / 24);
1528
- data.days = days % 30;
1529
-
1530
- months += absRound(days / 30);
1531
- data.months = months % 12;
1532
-
1533
- years = absRound(months / 12);
1534
- data.years = years;
1535
- },
1536
-
1537
- weeks : function () {
1538
- return absRound(this.days() / 7);
1539
- },
1540
-
1541
- valueOf : function () {
1542
- return this._milliseconds +
1543
- this._days * 864e5 +
1544
- (this._months % 12) * 2592e6 +
1545
- ~~(this._months / 12) * 31536e6;
1546
- },
1547
-
1548
- humanize : function (withSuffix) {
1549
- var difference = +this,
1550
- output = relativeTime(difference, !withSuffix, this.lang());
1551
-
1552
- if (withSuffix) {
1553
- output = this.lang().pastFuture(difference, output);
1554
- }
1555
-
1556
- return this.lang().postformat(output);
1557
- },
1558
-
1559
- add : function (input, val) {
1560
- // supports only 2.0-style add(1, 's') or add(moment)
1561
- var dur = moment.duration(input, val);
1562
-
1563
- this._milliseconds += dur._milliseconds;
1564
- this._days += dur._days;
1565
- this._months += dur._months;
1566
-
1567
- this._bubble();
1568
-
1569
- return this;
1570
- },
1571
-
1572
- subtract : function (input, val) {
1573
- var dur = moment.duration(input, val);
1574
-
1575
- this._milliseconds -= dur._milliseconds;
1576
- this._days -= dur._days;
1577
- this._months -= dur._months;
1578
-
1579
- this._bubble();
1580
-
1581
- return this;
1582
- },
1583
-
1584
- get : function (units) {
1585
- units = normalizeUnits(units);
1586
- return this[units.toLowerCase() + 's']();
1587
- },
1588
-
1589
- as : function (units) {
1590
- units = normalizeUnits(units);
1591
- return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's']();
1592
- },
1593
-
1594
- lang : moment.fn.lang
1595
- };
1596
-
1597
- function makeDurationGetter(name) {
1598
- moment.duration.fn[name] = function () {
1599
- return this._data[name];
1600
- };
1601
- }
1602
-
1603
- function makeDurationAsGetter(name, factor) {
1604
- moment.duration.fn['as' + name] = function () {
1605
- return +this / factor;
1606
- };
1607
- }
1608
-
1609
- for (i in unitMillisecondFactors) {
1610
- if (unitMillisecondFactors.hasOwnProperty(i)) {
1611
- makeDurationAsGetter(i, unitMillisecondFactors[i]);
1612
- makeDurationGetter(i.toLowerCase());
1613
- }
1614
- }
1615
-
1616
- makeDurationAsGetter('Weeks', 6048e5);
1617
- moment.duration.fn.asMonths = function () {
1618
- return (+this - this.years() * 31536e6) / 2592e6 + this.years() * 12;
1619
- };
1620
-
1621
-
1622
- /************************************
1623
- Default Lang
1624
- ************************************/
1625
-
1626
-
1627
- // Set default language, other languages will inherit from English.
1628
- moment.lang('en', {
1629
- ordinal : function (number) {
1630
- var b = number % 10,
1631
- output = (~~ (number % 100 / 10) === 1) ? 'th' :
1632
- (b === 1) ? 'st' :
1633
- (b === 2) ? 'nd' :
1634
- (b === 3) ? 'rd' : 'th';
1635
- return number + output;
1636
- }
1637
- });
1638
-
1639
-
1640
- /************************************
1641
- Exposing Moment
1642
- ************************************/
1643
-
1644
-
1645
- // CommonJS module is defined
1646
- if (hasModule) {
1647
- module.exports = moment;
1648
- }
1649
- /*global ender:false */
1650
- if (typeof ender === 'undefined') {
1651
- // here, `this` means `window` in the browser, or `global` on the server
1652
- // add `moment` as a global object via a string identifier,
1653
- // for Closure Compiler "advanced" mode
1654
- this['moment'] = moment;
1655
- }
1656
- /*global define:false */
1657
- if (typeof define === "function" && define.amd) {
1658
- define("moment", [], function () {
1659
- return moment;
1660
- });
1661
- }
1662
- }).call(this);