momentjs-rails 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/news.md +3 -0
- data/vendor/assets/javascripts/moment.js +185 -96
- data/vendor/assets/javascripts/moment/cs.js +3 -3
- data/vendor/assets/javascripts/moment/de.js +1 -1
- data/vendor/assets/javascripts/moment/es.js +13 -4
- data/vendor/assets/javascripts/moment/fi.js +6 -6
- data/vendor/assets/javascripts/moment/hu.js +7 -0
- data/vendor/assets/javascripts/moment/km.js +55 -0
- data/vendor/assets/javascripts/moment/lt.js +1 -1
- data/vendor/assets/javascripts/moment/nn.js +8 -8
- data/vendor/assets/javascripts/moment/pt-br.js +7 -7
- data/vendor/assets/javascripts/moment/pt.js +5 -5
- data/vendor/assets/javascripts/moment/ro.js +1 -1
- data/vendor/assets/javascripts/moment/ru.js +1 -1
- data/vendor/assets/javascripts/moment/sq.js +8 -4
- data/vendor/assets/javascripts/moment/sr-cyr.js +106 -0
- data/vendor/assets/javascripts/moment/sr.js +106 -0
- data/vendor/assets/javascripts/moment/vi.js +62 -0
- metadata +37 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74d6d3e55816936dd8d2c7d537ef55d40ea52426
|
4
|
+
data.tar.gz: 3ec6bebacc21a381364c4ee6a261d272d1c5b885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 200154bed35a9cbe22d2cdde5681b91e781973e2d10ab77ed3d20bdcec5578ad837f41374f836f1c32f9f05a2eff0ffb568ff37e2aac0f9bf6ac3d4f4542bf79
|
7
|
+
data.tar.gz: 3b87e36ee4c9e8f6a2895deaf8fc7436b400e3c94bc63e89e1003b1cd2e78dccb4ee6beb24e172a8e34684aef6decc39425004eed8eae2566088ddf9cb247d30
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ If you want to include a localization file, also add the following directive:
|
|
24
24
|
|
25
25
|
## Versioning
|
26
26
|
|
27
|
-
momentjs-rails 2.
|
27
|
+
momentjs-rails 2.6.0 == Moment.js 2.6.0
|
28
28
|
|
29
29
|
Every attempt is made to mirror the currently shipping Momentum.js version number wherever possible.
|
30
30
|
The major, minor, and patch version numbers will always represent the Momentum.js version. Should a gem
|
data/news.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
//! moment.js
|
2
|
-
//! version : 2.
|
2
|
+
//! version : 2.6.0
|
3
3
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
4
4
|
//! license : MIT
|
5
5
|
//! momentjs.com
|
@@ -11,8 +11,10 @@
|
|
11
11
|
************************************/
|
12
12
|
|
13
13
|
var moment,
|
14
|
-
VERSION = "2.
|
15
|
-
global
|
14
|
+
VERSION = "2.6.0",
|
15
|
+
// the global-scope this is NOT the global object in Node.js
|
16
|
+
globalScope = typeof global !== 'undefined' ? global : this,
|
17
|
+
oldGlobalMoment,
|
16
18
|
round = Math.round,
|
17
19
|
i,
|
18
20
|
|
@@ -41,7 +43,7 @@
|
|
41
43
|
},
|
42
44
|
|
43
45
|
// check for nodeJS
|
44
|
-
hasModule = (typeof module !== 'undefined' && module.exports
|
46
|
+
hasModule = (typeof module !== 'undefined' && module.exports),
|
45
47
|
|
46
48
|
// ASP.NET json date format regex
|
47
49
|
aspNetJsonRegex = /^\/?Date\((\-?\d+)/i,
|
@@ -52,7 +54,7 @@
|
|
52
54
|
isoDurationRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,
|
53
55
|
|
54
56
|
// format tokens
|
55
|
-
formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
|
57
|
+
formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,
|
56
58
|
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,
|
57
59
|
|
58
60
|
// parsing token regexes
|
@@ -65,6 +67,7 @@
|
|
65
67
|
parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z
|
66
68
|
parseTokenT = /T/i, // T (ISO separator)
|
67
69
|
parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123
|
70
|
+
parseTokenOrdinal = /\d{1,2}/,
|
68
71
|
|
69
72
|
//strict parsing regexes
|
70
73
|
parseTokenOneDigit = /\d/, // 0 - 9
|
@@ -90,7 +93,7 @@
|
|
90
93
|
|
91
94
|
// iso time formats and regexes
|
92
95
|
isoTimes = [
|
93
|
-
['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d
|
96
|
+
['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
|
94
97
|
['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
|
95
98
|
['HH:mm', /(T| )\d\d:\d\d/],
|
96
99
|
['HH', /(T| )\d\d/]
|
@@ -121,6 +124,7 @@
|
|
121
124
|
w : 'week',
|
122
125
|
W : 'isoWeek',
|
123
126
|
M : 'month',
|
127
|
+
Q : 'quarter',
|
124
128
|
y : 'year',
|
125
129
|
DDD : 'dayOfYear',
|
126
130
|
e : 'weekday',
|
@@ -296,6 +300,23 @@
|
|
296
300
|
};
|
297
301
|
}
|
298
302
|
|
303
|
+
function deprecate(msg, fn) {
|
304
|
+
var firstTime = true;
|
305
|
+
function printMsg() {
|
306
|
+
if (moment.suppressDeprecationWarnings === false &&
|
307
|
+
typeof console !== 'undefined' && console.warn) {
|
308
|
+
console.warn("Deprecation warning: " + msg);
|
309
|
+
}
|
310
|
+
}
|
311
|
+
return extend(function () {
|
312
|
+
if (firstTime) {
|
313
|
+
printMsg();
|
314
|
+
firstTime = false;
|
315
|
+
}
|
316
|
+
return fn.apply(this, arguments);
|
317
|
+
}, fn);
|
318
|
+
}
|
319
|
+
|
299
320
|
function padToken(func, count) {
|
300
321
|
return function (a) {
|
301
322
|
return leftZeroFill(func.call(this, a), count);
|
@@ -336,6 +357,7 @@
|
|
336
357
|
function Duration(duration) {
|
337
358
|
var normalizedInput = normalizeObjectUnits(duration),
|
338
359
|
years = normalizedInput.year || 0,
|
360
|
+
quarters = normalizedInput.quarter || 0,
|
339
361
|
months = normalizedInput.month || 0,
|
340
362
|
weeks = normalizedInput.week || 0,
|
341
363
|
days = normalizedInput.day || 0,
|
@@ -357,6 +379,7 @@
|
|
357
379
|
// which months you are are talking about, so we have to store
|
358
380
|
// it separately.
|
359
381
|
this._months = +months +
|
382
|
+
quarters * 3 +
|
360
383
|
years * 12;
|
361
384
|
|
362
385
|
this._data = {};
|
@@ -419,34 +442,23 @@
|
|
419
442
|
}
|
420
443
|
|
421
444
|
// helper function for _.addTime and _.subtractTime
|
422
|
-
function addOrSubtractDurationFromMoment(mom, duration, isAdding,
|
445
|
+
function addOrSubtractDurationFromMoment(mom, duration, isAdding, updateOffset) {
|
423
446
|
var milliseconds = duration._milliseconds,
|
424
447
|
days = duration._days,
|
425
|
-
months = duration._months
|
426
|
-
|
427
|
-
hours;
|
448
|
+
months = duration._months;
|
449
|
+
updateOffset = updateOffset == null ? true : updateOffset;
|
428
450
|
|
429
451
|
if (milliseconds) {
|
430
452
|
mom._d.setTime(+mom._d + milliseconds * isAdding);
|
431
453
|
}
|
432
|
-
// store the minutes and hours so we can restore them
|
433
|
-
if (days || months) {
|
434
|
-
minutes = mom.minute();
|
435
|
-
hours = mom.hour();
|
436
|
-
}
|
437
454
|
if (days) {
|
438
|
-
mom
|
455
|
+
rawSetter(mom, 'Date', rawGetter(mom, 'Date') + days * isAdding);
|
439
456
|
}
|
440
457
|
if (months) {
|
441
|
-
mom
|
458
|
+
rawMonthSetter(mom, rawGetter(mom, 'Month') + months * isAdding);
|
442
459
|
}
|
443
|
-
if (
|
444
|
-
moment.updateOffset(mom);
|
445
|
-
}
|
446
|
-
// restore the minutes and hours after possibly changing dst
|
447
|
-
if (days || months) {
|
448
|
-
mom.minute(minutes);
|
449
|
-
mom.hour(hours);
|
460
|
+
if (updateOffset) {
|
461
|
+
moment.updateOffset(mom, days || months);
|
450
462
|
}
|
451
463
|
}
|
452
464
|
|
@@ -561,6 +573,10 @@
|
|
561
573
|
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
562
574
|
}
|
563
575
|
|
576
|
+
function weeksInYear(year, dow, doy) {
|
577
|
+
return weekOfYear(moment([year, 11, 31 + dow - doy]), dow, doy).week;
|
578
|
+
}
|
579
|
+
|
564
580
|
function daysInYear(year) {
|
565
581
|
return isLeapYear(year) ? 366 : 365;
|
566
582
|
}
|
@@ -951,6 +967,8 @@
|
|
951
967
|
function getParseRegexForToken(token, config) {
|
952
968
|
var a, strict = config._strict;
|
953
969
|
switch (token) {
|
970
|
+
case 'Q':
|
971
|
+
return parseTokenOneDigit;
|
954
972
|
case 'DDDD':
|
955
973
|
return parseTokenThreeDigits;
|
956
974
|
case 'YYYY':
|
@@ -1019,6 +1037,8 @@
|
|
1019
1037
|
case 'e':
|
1020
1038
|
case 'E':
|
1021
1039
|
return parseTokenOneOrTwoDigits;
|
1040
|
+
case 'Do':
|
1041
|
+
return parseTokenOrdinal;
|
1022
1042
|
default :
|
1023
1043
|
a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i"));
|
1024
1044
|
return a;
|
@@ -1040,6 +1060,12 @@
|
|
1040
1060
|
var a, datePartArray = config._a;
|
1041
1061
|
|
1042
1062
|
switch (token) {
|
1063
|
+
// QUARTER
|
1064
|
+
case 'Q':
|
1065
|
+
if (input != null) {
|
1066
|
+
datePartArray[MONTH] = (toInt(input) - 1) * 3;
|
1067
|
+
}
|
1068
|
+
break;
|
1043
1069
|
// MONTH
|
1044
1070
|
case 'M' : // fall through to MM
|
1045
1071
|
case 'MM' :
|
@@ -1064,6 +1090,11 @@
|
|
1064
1090
|
datePartArray[DATE] = toInt(input);
|
1065
1091
|
}
|
1066
1092
|
break;
|
1093
|
+
case 'Do' :
|
1094
|
+
if (input != null) {
|
1095
|
+
datePartArray[DATE] = toInt(parseInt(input, 10));
|
1096
|
+
}
|
1097
|
+
break;
|
1067
1098
|
// DAY OF YEAR
|
1068
1099
|
case 'DDD' : // fall through to DDDD
|
1069
1100
|
case 'DDDD' :
|
@@ -1074,7 +1105,7 @@
|
|
1074
1105
|
break;
|
1075
1106
|
// YEAR
|
1076
1107
|
case 'YY' :
|
1077
|
-
datePartArray[YEAR] =
|
1108
|
+
datePartArray[YEAR] = moment.parseTwoDigitYear(input);
|
1078
1109
|
break;
|
1079
1110
|
case 'YYYY' :
|
1080
1111
|
case 'YYYYY' :
|
@@ -1163,9 +1194,9 @@
|
|
1163
1194
|
//compute day of the year from weeks and weekdays
|
1164
1195
|
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
1165
1196
|
fixYear = function (val) {
|
1166
|
-
var
|
1197
|
+
var intVal = parseInt(val, 10);
|
1167
1198
|
return val ?
|
1168
|
-
(val.length < 3 ? (
|
1199
|
+
(val.length < 3 ? (intVal > 68 ? 1900 + intVal : 2000 + intVal) : intVal) :
|
1169
1200
|
(config._a[YEAR] == null ? moment().weekYear() : config._a[YEAR]);
|
1170
1201
|
};
|
1171
1202
|
|
@@ -1401,7 +1432,7 @@
|
|
1401
1432
|
makeDateFromStringAndFormat(config);
|
1402
1433
|
}
|
1403
1434
|
else {
|
1404
|
-
|
1435
|
+
moment.createFromInputFallback(config);
|
1405
1436
|
}
|
1406
1437
|
}
|
1407
1438
|
|
@@ -1422,8 +1453,11 @@
|
|
1422
1453
|
config._d = new Date(+input);
|
1423
1454
|
} else if (typeof(input) === 'object') {
|
1424
1455
|
dateFromObject(config);
|
1425
|
-
} else {
|
1456
|
+
} else if (typeof(input) === 'number') {
|
1457
|
+
// from milliseconds
|
1426
1458
|
config._d = new Date(input);
|
1459
|
+
} else {
|
1460
|
+
moment.createFromInputFallback(config);
|
1427
1461
|
}
|
1428
1462
|
}
|
1429
1463
|
|
@@ -1550,7 +1584,7 @@
|
|
1550
1584
|
var input = config._i,
|
1551
1585
|
format = config._f;
|
1552
1586
|
|
1553
|
-
if (input === null) {
|
1587
|
+
if (input === null || (format === undefined && input === '')) {
|
1554
1588
|
return moment.invalid({nullInput: true});
|
1555
1589
|
}
|
1556
1590
|
|
@@ -1596,6 +1630,17 @@
|
|
1596
1630
|
return makeMoment(c);
|
1597
1631
|
};
|
1598
1632
|
|
1633
|
+
moment.suppressDeprecationWarnings = false;
|
1634
|
+
|
1635
|
+
moment.createFromInputFallback = deprecate(
|
1636
|
+
"moment construction falls back to js Date. This is " +
|
1637
|
+
"discouraged and will be removed in upcoming major " +
|
1638
|
+
"release. Please refer to " +
|
1639
|
+
"https://github.com/moment/moment/issues/1407 for more info.",
|
1640
|
+
function (config) {
|
1641
|
+
config._d = new Date(config._i);
|
1642
|
+
});
|
1643
|
+
|
1599
1644
|
// creating with utc
|
1600
1645
|
moment.utc = function (input, format, lang, strict) {
|
1601
1646
|
var c;
|
@@ -1692,6 +1737,10 @@
|
|
1692
1737
|
// default format
|
1693
1738
|
moment.defaultFormat = isoFormat;
|
1694
1739
|
|
1740
|
+
// Plugins that add properties should also add the key here (null value),
|
1741
|
+
// so we can properly clone ourselves.
|
1742
|
+
moment.momentProperties = momentProperties;
|
1743
|
+
|
1695
1744
|
// This function will be called whenever a moment is mutated.
|
1696
1745
|
// It is intended to keep the offset in sync with the timezone.
|
1697
1746
|
moment.updateOffset = function () {};
|
@@ -1755,8 +1804,12 @@
|
|
1755
1804
|
return m;
|
1756
1805
|
};
|
1757
1806
|
|
1758
|
-
moment.parseZone = function (
|
1759
|
-
return moment(
|
1807
|
+
moment.parseZone = function () {
|
1808
|
+
return moment.apply(null, arguments).parseZone();
|
1809
|
+
};
|
1810
|
+
|
1811
|
+
moment.parseTwoDigitYear = function (input) {
|
1812
|
+
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
1760
1813
|
};
|
1761
1814
|
|
1762
1815
|
/************************************
|
@@ -1943,29 +1996,7 @@
|
|
1943
1996
|
}
|
1944
1997
|
},
|
1945
1998
|
|
1946
|
-
month :
|
1947
|
-
var utc = this._isUTC ? 'UTC' : '',
|
1948
|
-
dayOfMonth;
|
1949
|
-
|
1950
|
-
if (input != null) {
|
1951
|
-
if (typeof input === 'string') {
|
1952
|
-
input = this.lang().monthsParse(input);
|
1953
|
-
if (typeof input !== 'number') {
|
1954
|
-
return this;
|
1955
|
-
}
|
1956
|
-
}
|
1957
|
-
|
1958
|
-
dayOfMonth = this.date();
|
1959
|
-
this.date(1);
|
1960
|
-
this._d['set' + utc + 'Month'](input);
|
1961
|
-
this.date(Math.min(dayOfMonth, this.daysInMonth()));
|
1962
|
-
|
1963
|
-
moment.updateOffset(this);
|
1964
|
-
return this;
|
1965
|
-
} else {
|
1966
|
-
return this._d['get' + utc + 'Month']();
|
1967
|
-
}
|
1968
|
-
},
|
1999
|
+
month : makeAccessor('Month', true),
|
1969
2000
|
|
1970
2001
|
startOf: function (units) {
|
1971
2002
|
units = normalizeUnits(units);
|
@@ -1975,6 +2006,7 @@
|
|
1975
2006
|
case 'year':
|
1976
2007
|
this.month(0);
|
1977
2008
|
/* falls through */
|
2009
|
+
case 'quarter':
|
1978
2010
|
case 'month':
|
1979
2011
|
this.date(1);
|
1980
2012
|
/* falls through */
|
@@ -2001,6 +2033,11 @@
|
|
2001
2033
|
this.isoWeekday(1);
|
2002
2034
|
}
|
2003
2035
|
|
2036
|
+
// quarters are also special
|
2037
|
+
if (units === 'quarter') {
|
2038
|
+
this.month(Math.floor(this.month() / 3) * 3);
|
2039
|
+
}
|
2040
|
+
|
2004
2041
|
return this;
|
2005
2042
|
},
|
2006
2043
|
|
@@ -2034,7 +2071,17 @@
|
|
2034
2071
|
return other > this ? this : other;
|
2035
2072
|
},
|
2036
2073
|
|
2037
|
-
|
2074
|
+
// keepTime = true means only change the timezone, without affecting
|
2075
|
+
// the local hour. So 5:31:26 +0300 --[zone(2, true)]--> 5:31:26 +0200
|
2076
|
+
// It is possible that 5:31:26 doesn't exist int zone +0200, so we
|
2077
|
+
// adjust the time as needed, to be valid.
|
2078
|
+
//
|
2079
|
+
// Keeping the time actually adds/subtracts (one hour)
|
2080
|
+
// from the actual represented time. That is why we call updateOffset
|
2081
|
+
// a second time. In case it wants us to change the offset again
|
2082
|
+
// _changeInProgress == true case, then we have to adjust, because
|
2083
|
+
// there is no such time in the given timezone.
|
2084
|
+
zone : function (input, keepTime) {
|
2038
2085
|
var offset = this._offset || 0;
|
2039
2086
|
if (input != null) {
|
2040
2087
|
if (typeof input === "string") {
|
@@ -2046,7 +2093,14 @@
|
|
2046
2093
|
this._offset = input;
|
2047
2094
|
this._isUTC = true;
|
2048
2095
|
if (offset !== input) {
|
2049
|
-
|
2096
|
+
if (!keepTime || this._changeInProgress) {
|
2097
|
+
addOrSubtractDurationFromMoment(this,
|
2098
|
+
moment.duration(offset - input, 'm'), 1, false);
|
2099
|
+
} else if (!this._changeInProgress) {
|
2100
|
+
this._changeInProgress = true;
|
2101
|
+
moment.updateOffset(this, true);
|
2102
|
+
this._changeInProgress = null;
|
2103
|
+
}
|
2050
2104
|
}
|
2051
2105
|
} else {
|
2052
2106
|
return this._isUTC ? offset : this._d.getTimezoneOffset();
|
@@ -2091,8 +2145,8 @@
|
|
2091
2145
|
return input == null ? dayOfYear : this.add("d", (input - dayOfYear));
|
2092
2146
|
},
|
2093
2147
|
|
2094
|
-
quarter : function () {
|
2095
|
-
return Math.ceil((this.month() + 1
|
2148
|
+
quarter : function (input) {
|
2149
|
+
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
2096
2150
|
},
|
2097
2151
|
|
2098
2152
|
weekYear : function (input) {
|
@@ -2127,6 +2181,15 @@
|
|
2127
2181
|
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
2128
2182
|
},
|
2129
2183
|
|
2184
|
+
isoWeeksInYear : function () {
|
2185
|
+
return weeksInYear(this.year(), 1, 4);
|
2186
|
+
},
|
2187
|
+
|
2188
|
+
weeksInYear : function () {
|
2189
|
+
var weekInfo = this._lang._week;
|
2190
|
+
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
2191
|
+
},
|
2192
|
+
|
2130
2193
|
get : function (units) {
|
2131
2194
|
units = normalizeUnits(units);
|
2132
2195
|
return this[units]();
|
@@ -2153,33 +2216,68 @@
|
|
2153
2216
|
}
|
2154
2217
|
});
|
2155
2218
|
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2219
|
+
function rawMonthSetter(mom, value) {
|
2220
|
+
var dayOfMonth;
|
2221
|
+
|
2222
|
+
// TODO: Move this out of here!
|
2223
|
+
if (typeof value === 'string') {
|
2224
|
+
value = mom.lang().monthsParse(value);
|
2225
|
+
// TODO: Another silent failure?
|
2226
|
+
if (typeof value !== 'number') {
|
2227
|
+
return mom;
|
2228
|
+
}
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
dayOfMonth = Math.min(mom.date(),
|
2232
|
+
daysInMonth(mom.year(), value));
|
2233
|
+
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
2234
|
+
return mom;
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
function rawGetter(mom, unit) {
|
2238
|
+
return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
|
2239
|
+
}
|
2240
|
+
|
2241
|
+
function rawSetter(mom, unit, value) {
|
2242
|
+
if (unit === 'Month') {
|
2243
|
+
return rawMonthSetter(mom, value);
|
2244
|
+
} else {
|
2245
|
+
return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
2246
|
+
}
|
2247
|
+
}
|
2248
|
+
|
2249
|
+
function makeAccessor(unit, keepTime) {
|
2250
|
+
return function (value) {
|
2251
|
+
if (value != null) {
|
2252
|
+
rawSetter(this, unit, value);
|
2253
|
+
moment.updateOffset(this, keepTime);
|
2163
2254
|
return this;
|
2164
2255
|
} else {
|
2165
|
-
return this
|
2256
|
+
return rawGetter(this, unit);
|
2166
2257
|
}
|
2167
2258
|
};
|
2168
2259
|
}
|
2169
2260
|
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
//
|
2176
|
-
|
2261
|
+
moment.fn.millisecond = moment.fn.milliseconds = makeAccessor('Milliseconds', false);
|
2262
|
+
moment.fn.second = moment.fn.seconds = makeAccessor('Seconds', false);
|
2263
|
+
moment.fn.minute = moment.fn.minutes = makeAccessor('Minutes', false);
|
2264
|
+
// Setting the hour should keep the time, because the user explicitly
|
2265
|
+
// specified which hour he wants. So trying to maintain the same hour (in
|
2266
|
+
// a new timezone) makes sense. Adding/subtracting hours does not follow
|
2267
|
+
// this rule.
|
2268
|
+
moment.fn.hour = moment.fn.hours = makeAccessor('Hours', true);
|
2269
|
+
// moment.fn.month is defined separately
|
2270
|
+
moment.fn.date = makeAccessor('Date', true);
|
2271
|
+
moment.fn.dates = deprecate("dates accessor is deprecated. Use date instead.", makeAccessor('Date', true));
|
2272
|
+
moment.fn.year = makeAccessor('FullYear', true);
|
2273
|
+
moment.fn.years = deprecate("years accessor is deprecated. Use year instead.", makeAccessor('FullYear', true));
|
2177
2274
|
|
2178
2275
|
// add plural methods
|
2179
2276
|
moment.fn.days = moment.fn.day;
|
2180
2277
|
moment.fn.months = moment.fn.month;
|
2181
2278
|
moment.fn.weeks = moment.fn.week;
|
2182
2279
|
moment.fn.isoWeeks = moment.fn.isoWeek;
|
2280
|
+
moment.fn.quarters = moment.fn.quarter;
|
2183
2281
|
|
2184
2282
|
// add aliased format methods
|
2185
2283
|
moment.fn.toJSON = moment.fn.toISOString;
|
@@ -2355,45 +2453,36 @@
|
|
2355
2453
|
Exposing Moment
|
2356
2454
|
************************************/
|
2357
2455
|
|
2358
|
-
function makeGlobal(
|
2359
|
-
var warned = false, local_moment = moment;
|
2456
|
+
function makeGlobal(shouldDeprecate) {
|
2360
2457
|
/*global ender:false */
|
2361
2458
|
if (typeof ender !== 'undefined') {
|
2362
2459
|
return;
|
2363
2460
|
}
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2368
|
-
|
2369
|
-
|
2370
|
-
|
2371
|
-
console.warn(
|
2372
|
-
"Accessing Moment through the global scope is " +
|
2373
|
-
"deprecated, and will be removed in an upcoming " +
|
2374
|
-
"release.");
|
2375
|
-
}
|
2376
|
-
return local_moment.apply(null, arguments);
|
2377
|
-
};
|
2378
|
-
extend(global.moment, local_moment);
|
2461
|
+
oldGlobalMoment = globalScope.moment;
|
2462
|
+
if (shouldDeprecate) {
|
2463
|
+
globalScope.moment = deprecate(
|
2464
|
+
"Accessing Moment through the global scope is " +
|
2465
|
+
"deprecated, and will be removed in an upcoming " +
|
2466
|
+
"release.",
|
2467
|
+
moment);
|
2379
2468
|
} else {
|
2380
|
-
|
2469
|
+
globalScope.moment = moment;
|
2381
2470
|
}
|
2382
2471
|
}
|
2383
2472
|
|
2384
2473
|
// CommonJS module is defined
|
2385
2474
|
if (hasModule) {
|
2386
2475
|
module.exports = moment;
|
2387
|
-
makeGlobal(true);
|
2388
2476
|
} else if (typeof define === "function" && define.amd) {
|
2389
2477
|
define("moment", function (require, exports, module) {
|
2390
|
-
if (module.config && module.config() && module.config().noGlobal
|
2391
|
-
//
|
2392
|
-
|
2478
|
+
if (module.config && module.config() && module.config().noGlobal === true) {
|
2479
|
+
// release the global variable
|
2480
|
+
globalScope.moment = oldGlobalMoment;
|
2393
2481
|
}
|
2394
2482
|
|
2395
2483
|
return moment;
|
2396
2484
|
});
|
2485
|
+
makeGlobal(true);
|
2397
2486
|
} else {
|
2398
2487
|
makeGlobal();
|
2399
2488
|
}
|