mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
updated sugar
This commit is contained in:
parent
4dde10f731
commit
fece8bfe18
@ -19,6 +19,9 @@
|
|||||||
// Internal toString
|
// Internal toString
|
||||||
var internalToString = object.prototype.toString;
|
var internalToString = object.prototype.toString;
|
||||||
|
|
||||||
|
// Internal hasOwnProperty
|
||||||
|
var hasOwnProperty = object.hasOwnProperty;
|
||||||
|
|
||||||
// The global context
|
// The global context
|
||||||
var globalContext = typeof global !== 'undefined' ? global : this;
|
var globalContext = typeof global !== 'undefined' ? global : this;
|
||||||
|
|
||||||
@ -100,7 +103,7 @@
|
|||||||
initializeClass(klass);
|
initializeClass(klass);
|
||||||
iterateOverObject(methods, function(name, method) {
|
iterateOverObject(methods, function(name, method) {
|
||||||
var original = extendee[name];
|
var original = extendee[name];
|
||||||
var existed = hasOwnProperty(extendee, name);
|
var existed = hasOwnProperty.call(extendee, name);
|
||||||
if(typeof override === 'function') {
|
if(typeof override === 'function') {
|
||||||
method = wrapNative(extendee[name], method, override);
|
method = wrapNative(extendee[name], method, override);
|
||||||
}
|
}
|
||||||
@ -199,8 +202,8 @@
|
|||||||
// Not own constructor property must be Object
|
// Not own constructor property must be Object
|
||||||
// This code was borrowed from jQuery.isPlainObject
|
// This code was borrowed from jQuery.isPlainObject
|
||||||
if (obj.constructor &&
|
if (obj.constructor &&
|
||||||
!hasOwnProperty(obj, 'constructor') &&
|
!hasOwnProperty.call(obj, 'constructor') &&
|
||||||
!hasOwnProperty(obj.constructor.prototype, 'isPrototypeOf')) {
|
!hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -210,18 +213,13 @@
|
|||||||
// === on the constructor is not safe across iframes
|
// === on the constructor is not safe across iframes
|
||||||
// 'hasOwnProperty' ensures that the object also inherits
|
// 'hasOwnProperty' ensures that the object also inherits
|
||||||
// from Object, which is false for DOMElements in IE.
|
// from Object, which is false for DOMElements in IE.
|
||||||
// AP: CAN THIS NOW BE REMOVED WITH THE CODE ABOVE IN PLACE???
|
|
||||||
return !!obj && klass === '[object Object]' && 'hasOwnProperty' in obj;
|
return !!obj && klass === '[object Object]' && 'hasOwnProperty' in obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasOwnProperty(obj, key) {
|
|
||||||
return object['hasOwnProperty'].call(obj, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
function iterateOverObject(obj, fn) {
|
function iterateOverObject(obj, fn) {
|
||||||
var key;
|
var key;
|
||||||
for(key in obj) {
|
for(key in obj) {
|
||||||
if(!hasOwnProperty(obj, key)) continue;
|
if(!hasOwnProperty.call(obj, key)) continue;
|
||||||
if(fn.call(obj, key, obj[key], obj) === false) break;
|
if(fn.call(obj, key, obj[key], obj) === false) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +295,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function repeatString(times, str) {
|
function repeatString(times, str) {
|
||||||
return array(math.max(0, isDefined(times) ? times : 1) + 1).join(str || '');
|
var result = '';
|
||||||
|
if(isUndefined(times)) {
|
||||||
|
times = 1;
|
||||||
|
}
|
||||||
|
while(times-- > 0) {
|
||||||
|
result += str;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,8 +363,8 @@
|
|||||||
if(type === 'string') return thing;
|
if(type === 'string') return thing;
|
||||||
|
|
||||||
klass = internalToString.call(thing)
|
klass = internalToString.call(thing)
|
||||||
thingIsArray = klass === '[object Array]';
|
thingIsObject = isPlainObject(thing, klass);
|
||||||
thingIsObject = isObjectPrimitive(thing) && !thingIsArray;
|
thingIsArray = isArray(thing, klass);
|
||||||
|
|
||||||
if(thing != null && thingIsObject || thingIsArray) {
|
if(thing != null && thingIsObject || thingIsArray) {
|
||||||
// This method for checking for cyclic structures was egregiously stolen from
|
// This method for checking for cyclic structures was egregiously stolen from
|
||||||
@ -1346,12 +1351,9 @@
|
|||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
'removeAt': function(start, end) {
|
'removeAt': function(start, end) {
|
||||||
var i, len;
|
|
||||||
if(isUndefined(start)) return this;
|
if(isUndefined(start)) return this;
|
||||||
if(isUndefined(end)) end = start;
|
if(isUndefined(end)) end = start;
|
||||||
for(i = 0, len = end - start; i <= len; i++) {
|
this.splice(start, end - start + 1);
|
||||||
this.splice(start, 1);
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2143,7 +2145,7 @@
|
|||||||
var SixtyReg = '[0-5]\\d' + DecimalReg;
|
var SixtyReg = '[0-5]\\d' + DecimalReg;
|
||||||
var RequiredTime = '({t})?\\s*('+HoursReg+')(?:{h}('+SixtyReg+')?{m}(?::?('+SixtyReg+'){s})?\\s*(?:({t})|(Z)|(?:([+-])(\\d{2,2})(?::?(\\d{2,2}))?)?)?|\\s*({t}))';
|
var RequiredTime = '({t})?\\s*('+HoursReg+')(?:{h}('+SixtyReg+')?{m}(?::?('+SixtyReg+'){s})?\\s*(?:({t})|(Z)|(?:([+-])(\\d{2,2})(?::?(\\d{2,2}))?)?)?|\\s*({t}))';
|
||||||
|
|
||||||
var KanjiDigits = '〇一二三四五六七八九十百千万';
|
var KanjiDigits = '〇一二三四五六七八九十百千万';
|
||||||
var FullWidthDigits = '0123456789';
|
var FullWidthDigits = '0123456789';
|
||||||
var AsianDigitMap = {};
|
var AsianDigitMap = {};
|
||||||
var AsianDigitReg;
|
var AsianDigitReg;
|
||||||
@ -2151,110 +2153,40 @@
|
|||||||
var DateArgumentUnits;
|
var DateArgumentUnits;
|
||||||
var DateUnitsReversed;
|
var DateUnitsReversed;
|
||||||
var CoreDateFormats = [];
|
var CoreDateFormats = [];
|
||||||
|
var CompiledOutputFormats = {};
|
||||||
|
|
||||||
var DateOutputFormats = [
|
var DateFormatTokens = {
|
||||||
{
|
|
||||||
token: 'f{1,4}|ms|milliseconds',
|
'yyyy': function(d) {
|
||||||
format: function(d) {
|
return callDateGet(d, 'FullYear');
|
||||||
return callDateGet(d, 'Milliseconds');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'ss?|seconds',
|
'yy': function(d) {
|
||||||
format: function(d, len) {
|
return callDateGet(d, 'FullYear') % 100;
|
||||||
return callDateGet(d, 'Seconds');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'mm?|minutes',
|
'ord': function(d) {
|
||||||
format: function(d, len) {
|
var date = callDateGet(d, 'Date');
|
||||||
return callDateGet(d, 'Minutes');
|
return date + getOrdinalizedSuffix(date);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'hh?|hours|12hr',
|
'tz': function(d) {
|
||||||
format: function(d) {
|
return d.getUTCOffset();
|
||||||
return getShortHour(d);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'HH?|24hr',
|
'isotz': function(d) {
|
||||||
format: function(d) {
|
return d.getUTCOffset(true);
|
||||||
return callDateGet(d, 'Hours');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'dd?|date|day',
|
'Z': function(d) {
|
||||||
format: function(d) {
|
return d.getUTCOffset();
|
||||||
return callDateGet(d, 'Date');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
token: 'dow|weekday',
|
'ZZ': function(d) {
|
||||||
word: true,
|
return d.getUTCOffset().replace(/(\d{2})$/, ':$1');
|
||||||
format: function(d, loc, n, t) {
|
|
||||||
var dow = callDateGet(d, 'Day');
|
|
||||||
return loc['weekdays'][dow + (n - 1) * 7];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'MM?',
|
|
||||||
format: function(d) {
|
|
||||||
return callDateGet(d, 'Month') + 1;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'mon|month',
|
|
||||||
word: true,
|
|
||||||
format: function(d, loc, n, len) {
|
|
||||||
var month = callDateGet(d, 'Month');
|
|
||||||
return loc['months'][month + (n - 1) * 12];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'y{2,4}|year',
|
|
||||||
format: function(d) {
|
|
||||||
return callDateGet(d, 'FullYear');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: '[Tt]{1,2}',
|
|
||||||
format: function(d, loc, n, format) {
|
|
||||||
if(loc['ampm'].length == 0) return '';
|
|
||||||
var hours = callDateGet(d, 'Hours');
|
|
||||||
var str = loc['ampm'][floor(hours / 12)];
|
|
||||||
if(format.length === 1) str = str.slice(0,1);
|
|
||||||
if(format.slice(0,1) === 'T') str = str.toUpperCase();
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'z{1,4}|tz|timezone',
|
|
||||||
text: true,
|
|
||||||
format: function(d, loc, n, format) {
|
|
||||||
var tz = d.getUTCOffset();
|
|
||||||
if(format == 'z' || format == 'zz') {
|
|
||||||
tz = tz.replace(/(\d{2})(\d{2})/, function(f,h,m) {
|
|
||||||
return padNumber(h, format.length);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return tz;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'iso(tz|timezone)',
|
|
||||||
format: function(d) {
|
|
||||||
return d.getUTCOffset(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
token: 'ord',
|
|
||||||
format: function(d) {
|
|
||||||
var date = callDateGet(d, 'Date');
|
|
||||||
return date + getOrdinalizedSuffix(date);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
];
|
|
||||||
|
};
|
||||||
|
|
||||||
var DateUnits = [
|
var DateUnits = [
|
||||||
{
|
{
|
||||||
@ -2490,7 +2422,7 @@
|
|||||||
if(!isString(localeCode)) localeCode = '';
|
if(!isString(localeCode)) localeCode = '';
|
||||||
loc = Localizations[localeCode] || Localizations[localeCode.slice(0,2)];
|
loc = Localizations[localeCode] || Localizations[localeCode.slice(0,2)];
|
||||||
if(fallback === false && !loc) {
|
if(fallback === false && !loc) {
|
||||||
throw new Error('Invalid locale.');
|
throw new TypeError('Invalid locale.');
|
||||||
}
|
}
|
||||||
return loc || CurrentLocalization;
|
return loc || CurrentLocalization;
|
||||||
}
|
}
|
||||||
@ -2658,7 +2590,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDateParamsFromString(str, num) {
|
function getDateParamsFromString(str, num) {
|
||||||
var params = {};
|
var match, params = {};
|
||||||
match = str.match(/^(\d+)?\s?(\w+?)s?$/i);
|
match = str.match(/^(\d+)?\s?(\w+?)s?$/i);
|
||||||
if(match) {
|
if(match) {
|
||||||
if(isUndefined(num)) {
|
if(isUndefined(num)) {
|
||||||
@ -3038,17 +2970,105 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Date format token helpers
|
||||||
|
|
||||||
|
function createMeridianTokens(slice, caps) {
|
||||||
|
var fn = function(d, localeCode) {
|
||||||
|
var hours = callDateGet(d, 'Hours');
|
||||||
|
return getLocalization(localeCode)['ampm'][floor(hours / 12)] || '';
|
||||||
|
}
|
||||||
|
createFormatToken('t', fn, 1);
|
||||||
|
createFormatToken('tt', fn);
|
||||||
|
createFormatToken('T', fn, 1, 1);
|
||||||
|
createFormatToken('TT', fn, null, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWeekdayTokens(slice, caps) {
|
||||||
|
var fn = function(d, localeCode) {
|
||||||
|
var dow = callDateGet(d, 'Day');
|
||||||
|
return getLocalization(localeCode)['weekdays'][dow];
|
||||||
|
}
|
||||||
|
createFormatToken('dow', fn, 3);
|
||||||
|
createFormatToken('Dow', fn, 3, 1);
|
||||||
|
createFormatToken('weekday', fn);
|
||||||
|
createFormatToken('Weekday', fn, null, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMonthTokens(slice, caps) {
|
||||||
|
createMonthToken('mon', 0, 3);
|
||||||
|
createMonthToken('month', 0);
|
||||||
|
|
||||||
|
// For inflected month forms, namely Russian.
|
||||||
|
createMonthToken('month2', 1);
|
||||||
|
createMonthToken('month3', 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMonthToken(token, multiplier, slice) {
|
||||||
|
var fn = function(d, localeCode) {
|
||||||
|
var month = callDateGet(d, 'Month');
|
||||||
|
return getLocalization(localeCode)['months'][month + (multiplier * 12)];
|
||||||
|
};
|
||||||
|
createFormatToken(token, fn, slice);
|
||||||
|
createFormatToken(simpleCapitalize(token), fn, slice, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFormatToken(t, fn, slice, caps) {
|
||||||
|
DateFormatTokens[t] = function(d, localeCode) {
|
||||||
|
var str = fn(d, localeCode);
|
||||||
|
if(slice) str = str.slice(0, slice);
|
||||||
|
if(caps) str = str.slice(0, caps).toUpperCase() + str.slice(caps);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPaddedToken(t, fn, ms) {
|
||||||
|
DateFormatTokens[t] = fn;
|
||||||
|
DateFormatTokens[t + t] = function (d, localeCode) {
|
||||||
|
return padNumber(fn(d, localeCode), 2);
|
||||||
|
};
|
||||||
|
if(ms) {
|
||||||
|
DateFormatTokens[t + t + t] = function (d, localeCode) {
|
||||||
|
return padNumber(fn(d, localeCode), 3);
|
||||||
|
};
|
||||||
|
DateFormatTokens[t + t + t + t] = function (d, localeCode) {
|
||||||
|
return padNumber(fn(d, localeCode), 4);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Date formatting helpers
|
// Date formatting helpers
|
||||||
|
|
||||||
|
function buildCompiledOutputFormat(format) {
|
||||||
|
var match = format.match(/(\{\w+\})|[^{}]+/g);
|
||||||
|
CompiledOutputFormats[format] = match.map(function(p) {
|
||||||
|
p.replace(/\{(\w+)\}/, function(full, token) {
|
||||||
|
p = DateFormatTokens[token] || token;
|
||||||
|
return token;
|
||||||
|
});
|
||||||
|
return p;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeCompiledOutputFormat(date, format, localeCode) {
|
||||||
|
var compiledFormat, length, i, t, result = '';
|
||||||
|
compiledFormat = CompiledOutputFormats[format];
|
||||||
|
for(i = 0, length = compiledFormat.length; i < length; i++) {
|
||||||
|
t = compiledFormat[i];
|
||||||
|
result += isFunction(t) ? t(date, localeCode) : t;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function formatDate(date, format, relative, localeCode) {
|
function formatDate(date, format, relative, localeCode) {
|
||||||
var adu, loc = getLocalization(localeCode), caps = regexp(/^[A-Z]/), value, shortcut;
|
var adu;
|
||||||
if(!date.isValid()) {
|
if(!date.isValid()) {
|
||||||
return 'Invalid Date';
|
return 'Invalid Date';
|
||||||
} else if(Date[format]) {
|
} else if(Date[format]) {
|
||||||
format = Date[format];
|
format = Date[format];
|
||||||
} else if(isFunction(format)) {
|
} else if(isFunction(format)) {
|
||||||
adu = getRelativeWithMonthFallback(date);
|
adu = getRelativeWithMonthFallback(date);
|
||||||
format = format.apply(date, adu.concat(loc));
|
format = format.apply(date, adu.concat(getLocalization(localeCode)));
|
||||||
}
|
}
|
||||||
if(!format && relative) {
|
if(!format && relative) {
|
||||||
adu = adu || getRelativeWithMonthFallback(date);
|
adu = adu || getRelativeWithMonthFallback(date);
|
||||||
@ -3058,32 +3078,25 @@
|
|||||||
adu[1] = 1;
|
adu[1] = 1;
|
||||||
adu[0] = 1;
|
adu[0] = 1;
|
||||||
}
|
}
|
||||||
return loc.getRelativeFormat(adu);
|
return getLocalization(localeCode).getRelativeFormat(adu);
|
||||||
|
}
|
||||||
|
format = format || 'long';
|
||||||
|
if(format === 'short' || format === 'long' || format === 'full') {
|
||||||
|
format = getLocalization(localeCode)[format];
|
||||||
}
|
}
|
||||||
|
|
||||||
format = format || 'long';
|
if(!CompiledOutputFormats[format]) {
|
||||||
format = loc[format] || format;
|
buildCompiledOutputFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
DateOutputFormats.forEach(function(dof) {
|
return executeCompiledOutputFormat(date, format, localeCode);
|
||||||
format = format.replace(regexp('\\{('+dof.token+')(\\d)?\\}', dof.word ? 'i' : ''), function(m,t,d) {
|
|
||||||
var val = dof.format(date, loc, d || 1, t), l = t.length, one = t.match(/^(.)\1+$/);
|
|
||||||
if(dof.word) {
|
|
||||||
if(l === 3) val = val.slice(0,3);
|
|
||||||
if(one || t.match(caps)) val = simpleCapitalize(val);
|
|
||||||
} else if(one && !dof.text) {
|
|
||||||
val = (isNumber(val) ? padNumber(val, l) : val.toString()).slice(-l);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return format;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date comparison helpers
|
// Date comparison helpers
|
||||||
|
|
||||||
function compareDate(d, find, buffer, forceUTC) {
|
function compareDate(d, find, localeCode, buffer, forceUTC) {
|
||||||
var p, t, min, max, minOffset, maxOffset, override, capitalized, accuracy = 0, loBuffer = 0, hiBuffer = 0;
|
var p, t, min, max, minOffset, maxOffset, override, capitalized, accuracy = 0, loBuffer = 0, hiBuffer = 0;
|
||||||
p = getExtendedDate(find, null, null, forceUTC);
|
p = getExtendedDate(find, localeCode, null, forceUTC);
|
||||||
if(buffer > 0) {
|
if(buffer > 0) {
|
||||||
loBuffer = hiBuffer = buffer;
|
loBuffer = hiBuffer = buffer;
|
||||||
override = true;
|
override = true;
|
||||||
@ -3287,7 +3300,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function invalidateDate(d) {
|
function invalidateDate(d) {
|
||||||
d.setTime();
|
d.setTime(NaN);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDateUnits() {
|
function buildDateUnits() {
|
||||||
@ -3538,7 +3551,7 @@
|
|||||||
if(i < 3) {
|
if(i < 3) {
|
||||||
['Last','This','Next'].forEach(function(shift) {
|
['Last','This','Next'].forEach(function(shift) {
|
||||||
methods['is' + shift + caps] = function() {
|
methods['is' + shift + caps] = function() {
|
||||||
return this.is(shift + ' ' + name);
|
return compareDate(this, shift + ' ' + name, 'en');
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3585,7 +3598,55 @@
|
|||||||
English.compiledFormats = English.compiledFormats.slice(7).concat(CoreDateFormats);
|
English.compiledFormats = English.compiledFormats.slice(7).concat(CoreDateFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDateOutputShortcuts() {
|
function buildFormatTokens() {
|
||||||
|
|
||||||
|
createPaddedToken('f', function(d) {
|
||||||
|
return callDateGet(d, 'Milliseconds');
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
createPaddedToken('s', function(d) {
|
||||||
|
return callDateGet(d, 'Seconds');
|
||||||
|
});
|
||||||
|
|
||||||
|
createPaddedToken('m', function(d) {
|
||||||
|
return callDateGet(d, 'Minutes');
|
||||||
|
});
|
||||||
|
|
||||||
|
createPaddedToken('h', function(d) {
|
||||||
|
return callDateGet(d, 'Hours') % 12 || 12;
|
||||||
|
});
|
||||||
|
|
||||||
|
createPaddedToken('H', function(d) {
|
||||||
|
return callDateGet(d, 'Hours');
|
||||||
|
});
|
||||||
|
|
||||||
|
createPaddedToken('d', function(d) {
|
||||||
|
return callDateGet(d, 'Date');
|
||||||
|
});
|
||||||
|
|
||||||
|
createPaddedToken('M', function(d) {
|
||||||
|
return callDateGet(d, 'Month') + 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
createMeridianTokens();
|
||||||
|
createWeekdayTokens();
|
||||||
|
createMonthTokens();
|
||||||
|
|
||||||
|
// Aliases
|
||||||
|
DateFormatTokens['ms'] = DateFormatTokens['f'];
|
||||||
|
DateFormatTokens['milliseconds'] = DateFormatTokens['f'];
|
||||||
|
DateFormatTokens['seconds'] = DateFormatTokens['s'];
|
||||||
|
DateFormatTokens['minutes'] = DateFormatTokens['m'];
|
||||||
|
DateFormatTokens['hours'] = DateFormatTokens['h'];
|
||||||
|
DateFormatTokens['24hr'] = DateFormatTokens['H'];
|
||||||
|
DateFormatTokens['12hr'] = DateFormatTokens['h'];
|
||||||
|
DateFormatTokens['date'] = DateFormatTokens['d'];
|
||||||
|
DateFormatTokens['day'] = DateFormatTokens['d'];
|
||||||
|
DateFormatTokens['year'] = DateFormatTokens['yyyy'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildFormatShortcuts() {
|
||||||
extendSimilar(date, true, false, 'short,long,full', function(methods, name) {
|
extendSimilar(date, true, false, 'short,long,full', function(methods, name) {
|
||||||
methods[name] = function(localeCode) {
|
methods[name] = function(localeCode) {
|
||||||
return formatDate(this, name, false, localeCode);
|
return formatDate(this, name, false, localeCode);
|
||||||
@ -4111,12 +4172,12 @@
|
|||||||
* }); -> ex. 5 months ago
|
* }); -> ex. 5 months ago
|
||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
'relative': function(f, localeCode) {
|
'relative': function(fn, localeCode) {
|
||||||
if(isString(f)) {
|
if(isString(fn)) {
|
||||||
localeCode = f;
|
localeCode = fn;
|
||||||
f = null;
|
fn = null;
|
||||||
}
|
}
|
||||||
return formatDate(this, f, true, localeCode);
|
return formatDate(this, fn, true, localeCode);
|
||||||
},
|
},
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -4150,7 +4211,7 @@
|
|||||||
case (tmp = English['months'].indexOf(d) % 12) > -1: return callDateGet(comp, 'Month') === tmp;
|
case (tmp = English['months'].indexOf(d) % 12) > -1: return callDateGet(comp, 'Month') === tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return compareDate(this, d, margin, utc);
|
return compareDate(this, d, null, margin, utc);
|
||||||
},
|
},
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -4467,7 +4528,8 @@
|
|||||||
buildDateUnits();
|
buildDateUnits();
|
||||||
buildDateMethods();
|
buildDateMethods();
|
||||||
buildCoreInputFormats();
|
buildCoreInputFormats();
|
||||||
buildDateOutputShortcuts();
|
buildFormatTokens();
|
||||||
|
buildFormatShortcuts();
|
||||||
buildAsianDigits();
|
buildAsianDigits();
|
||||||
buildRelativeAliases();
|
buildRelativeAliases();
|
||||||
buildUTCAliases();
|
buildUTCAliases();
|
||||||
@ -5489,7 +5551,7 @@
|
|||||||
allKeys.forEach(function(k) {
|
allKeys.forEach(function(k) {
|
||||||
paramIsArray = !k || k.match(/^\d+$/);
|
paramIsArray = !k || k.match(/^\d+$/);
|
||||||
if(!key && isArray(obj)) key = obj.length;
|
if(!key && isArray(obj)) key = obj.length;
|
||||||
if(!hasOwnProperty(obj, key)) {
|
if(!hasOwnProperty.call(obj, key)) {
|
||||||
obj[key] = paramIsArray ? [] : {};
|
obj[key] = paramIsArray ? [] : {};
|
||||||
}
|
}
|
||||||
obj = obj[key];
|
obj = obj[key];
|
||||||
@ -5536,7 +5598,7 @@
|
|||||||
if(isRegExp(match)) {
|
if(isRegExp(match)) {
|
||||||
return match.test(key);
|
return match.test(key);
|
||||||
} else if(isObjectPrimitive(match)) {
|
} else if(isObjectPrimitive(match)) {
|
||||||
return hasOwnProperty(match, key);
|
return hasOwnProperty.call(match, key);
|
||||||
} else {
|
} else {
|
||||||
return key === string(match);
|
return key === string(match);
|
||||||
}
|
}
|
||||||
@ -5726,7 +5788,7 @@
|
|||||||
// their properties not being enumerable in < IE8.
|
// their properties not being enumerable in < IE8.
|
||||||
if(target && typeof source != 'string') {
|
if(target && typeof source != 'string') {
|
||||||
for(key in source) {
|
for(key in source) {
|
||||||
if(!hasOwnProperty(source, key) || !target) continue;
|
if(!hasOwnProperty.call(source, key) || !target) continue;
|
||||||
val = source[key];
|
val = source[key];
|
||||||
// Conflict!
|
// Conflict!
|
||||||
if(isDefined(target[key])) {
|
if(isDefined(target[key])) {
|
||||||
@ -5793,7 +5855,7 @@
|
|||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
'clone': function(obj, deep) {
|
'clone': function(obj, deep) {
|
||||||
var target;
|
var target, klass;
|
||||||
if(!isObjectPrimitive(obj)) {
|
if(!isObjectPrimitive(obj)) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -5810,7 +5872,7 @@
|
|||||||
} else if(isPlainObject(obj, klass)) {
|
} else if(isPlainObject(obj, klass)) {
|
||||||
target = {};
|
target = {};
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError('Invalid target.');
|
throw new TypeError('Clone must be a basic data type.');
|
||||||
}
|
}
|
||||||
return object.merge(target, obj, deep);
|
return object.merge(target, obj, deep);
|
||||||
},
|
},
|
||||||
@ -5891,7 +5953,7 @@
|
|||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
'has': function (obj, key) {
|
'has': function (obj, key) {
|
||||||
return hasOwnProperty(obj, key);
|
return hasOwnProperty.call(obj, key);
|
||||||
},
|
},
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -6914,7 +6976,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return this.replace(/\{([^{]+?)\}/g, function(m, key) {
|
return this.replace(/\{([^{]+?)\}/g, function(m, key) {
|
||||||
return hasOwnProperty(assign, key) ? assign[key] : m;
|
return hasOwnProperty.call(assign, key) ? assign[key] : m;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6935,7 +6997,6 @@
|
|||||||
|
|
||||||
buildBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=');
|
buildBase64('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=');
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
* @package Inflections
|
* @package Inflections
|
||||||
@ -7226,7 +7287,6 @@
|
|||||||
Inflector.irregular('sex', 'sexes');
|
Inflector.irregular('sex', 'sexes');
|
||||||
Inflector.irregular('move', 'moves');
|
Inflector.irregular('move', 'moves');
|
||||||
Inflector.irregular('save', 'saves');
|
Inflector.irregular('save', 'saves');
|
||||||
Inflector.irregular('save', 'saves');
|
|
||||||
Inflector.irregular('cow', 'kine');
|
Inflector.irregular('cow', 'kine');
|
||||||
Inflector.irregular('goose', 'geese');
|
Inflector.irregular('goose', 'geese');
|
||||||
Inflector.irregular('zombie', 'zombies');
|
Inflector.irregular('zombie', 'zombies');
|
||||||
@ -7285,7 +7345,7 @@
|
|||||||
var str = runReplacements(this, humans), acronym;
|
var str = runReplacements(this, humans), acronym;
|
||||||
str = str.replace(/_id$/g, '');
|
str = str.replace(/_id$/g, '');
|
||||||
str = str.replace(/(_)?([a-z\d]*)/gi, function(match, _, word){
|
str = str.replace(/(_)?([a-z\d]*)/gi, function(match, _, word){
|
||||||
acronym = hasOwnProperty(acronyms, word) ? acronyms[word] : null;
|
acronym = hasOwnProperty.call(acronyms, word) ? acronyms[word] : null;
|
||||||
return (_ ? ' ' : '') + (acronym || word.toLowerCase());
|
return (_ ? ' ' : '') + (acronym || word.toLowerCase());
|
||||||
});
|
});
|
||||||
return capitalize(str);
|
return capitalize(str);
|
||||||
|
Loading…
Reference in New Issue
Block a user