📄 scriptresource(2).axd
字号:
// Month, long name.
month = cultureInfo._getMonthIndex(matchGroup);
if ((month < 0) || (month > 11)) return null;
break;
case 'MMM':
// Month, short name.
month = cultureInfo._getAbbrMonthIndex(matchGroup);
if ((month < 0) || (month > 11)) return null;
break;
case 'M': case 'MM':
// Month.
var month = parseInt(matchGroup, 10) - 1;
if ((month < 0) || (month > 11)) return null;
break;
case 'y': case 'yy':
// 2-Digit Year.
year = Date._expandYear(dtf,parseInt(matchGroup, 10));
if ((year < 0) || (year > 9999)) return null;
break;
case 'yyyy':
// 4-Digit Year.
year = parseInt(matchGroup, 10);
if ((year < 0) || (year > 9999)) return null;
break;
case 'h': case 'hh':
// Hours (12-hour clock).
hour = parseInt(matchGroup, 10);
if (hour === 12) hour = 0;
if ((hour < 0) || (hour > 11)) return null;
break;
case 'H': case 'HH':
// Hours (24-hour clock).
hour = parseInt(matchGroup, 10);
if ((hour < 0) || (hour > 23)) return null;
break;
case 'm': case 'mm':
// Minutes.
min = parseInt(matchGroup, 10);
if ((min < 0) || (min > 59)) return null;
break;
case 's': case 'ss':
// Seconds.
sec = parseInt(matchGroup, 10);
if ((sec < 0) || (sec > 59)) return null;
break;
case 'tt': case 't':
// AM/PM designator.
var upperToken = matchGroup.toUpperCase();
pmHour = (upperToken === dtf.PMDesignator.toUpperCase());
if (!pmHour && (upperToken !== dtf.AMDesignator.toUpperCase())) return null;
break;
case 'f':
// Deciseconds.
msec = parseInt(matchGroup, 10) * 100;
if ((msec < 0) || (msec > 999)) return null;
break;
case 'ff':
// Centiseconds.
msec = parseInt(matchGroup, 10) * 10;
if ((msec < 0) || (msec > 999)) return null;
break;
case 'fff':
// Milliseconds.
msec = parseInt(matchGroup, 10);
if ((msec < 0) || (msec > 999)) return null;
break;
case 'dddd':
// Day of week.
weekDay = cultureInfo._getDayIndex(matchGroup);
if ((weekDay < 0) || (weekDay > 6)) return null;
break;
case 'ddd':
// Day of week.
weekDay = cultureInfo._getAbbrDayIndex(matchGroup);
if ((weekDay < 0) || (weekDay > 6)) return null;
break;
case 'zzz':
// Time zone offset in +/- hours:min.
var offsets = matchGroup.split(/:/);
if (offsets.length !== 2) return null;
var hourOffset = parseInt(offsets[0], 10);
if ((hourOffset < -12) || (hourOffset > 13)) return null;
var minOffset = parseInt(offsets[1], 10);
if ((minOffset < 0) || (minOffset > 59)) return null;
tzMinOffset = (hourOffset * 60) + (matchGroup.startsWith('-')? -minOffset : minOffset);
break;
case 'z': case 'zz':
// Time zone offset in +/- hours.
var hourOffset = parseInt(matchGroup, 10);
if ((hourOffset < -12) || (hourOffset > 13)) return null;
tzMinOffset = hourOffset * 60;
break;
}
}
}
var result = new Date();
if (year === null) {
year = result.getFullYear();
}
if (month === null) {
month = result.getMonth();
}
if (date === null) {
date = result.getDate();
}
// have to set year, month and date together to avoid overflow based on current date.
result.setFullYear(year, month, date);
// check to see if date overflowed for specified month (only checked 1-31 above).
if (result.getDate() !== date) return null;
// invalid day of week.
if ((weekDay !== null) && (result.getDay() !== weekDay)) {
return null;
}
// if pm designator token was found make sure the hours fit the 24-hour clock.
if (pmHour && (hour < 12)) {
hour += 12;
}
result.setHours(hour, min, sec, msec);
if (tzMinOffset !== null) {
// adjust timezone to utc before applying local offset.
var adjustedMin = result.getMinutes() - (tzMinOffset + result.getTimezoneOffset());
// Safari limits hours and minutes to the range of -127 to 127. We need to use setHours
// to ensure both these fields will not exceed this range. adjustedMin will range
// somewhere between -1440 and 1500, so we only need to split this into hours.
result.setHours(result.getHours() + parseInt(adjustedMin/60, 10), adjustedMin%60);
}
return result;
}
Date.prototype.format = function Date$format(format) {
/// <summary locid="M:J#Date.format" />
/// <param name="format" type="String"></param>
/// <returns type="String"></returns>
var e = Function._validateParams(arguments, [
{name: "format", type: String}
]);
if (e) throw e;
return this._toFormattedString(format, Sys.CultureInfo.InvariantCulture);
}
Date.prototype.localeFormat = function Date$localeFormat(format) {
/// <summary locid="M:J#Date.localeFormat" />
/// <param name="format" type="String"></param>
/// <returns type="String"></returns>
var e = Function._validateParams(arguments, [
{name: "format", type: String}
]);
if (e) throw e;
return this._toFormattedString(format, Sys.CultureInfo.CurrentCulture);
}
Date.prototype._toFormattedString = function Date$_toFormattedString(format, cultureInfo) {
if (!format || (format.length === 0) || (format === 'i')) {
if (cultureInfo && (cultureInfo.name.length > 0)) {
return this.toLocaleString();
}
else {
return this.toString();
}
}
var dtf = cultureInfo.dateTimeFormat;
format = Date._expandFormat(dtf, format);
// Start with an empty string
var ret = new Sys.StringBuilder();
var hour;
function addLeadingZero(num) {
if (num < 10) {
return '0' + num;
}
return num.toString();
}
function addLeadingZeros(num) {
if (num < 10) {
return '00' + num;
}
if (num < 100) {
return '0' + num;
}
return num.toString();
}
var quoteCount = 0;
var tokenRegExp = Date._getTokenRegExp();
for (;;) {
// Save the current index
var index = tokenRegExp.lastIndex;
// Look for the next pattern
var ar = tokenRegExp.exec(format);
// Append the text before the pattern (or the end of the string if not found)
var preMatch = format.slice(index, ar ? ar.index : format.length);
quoteCount += Date._appendPreOrPostMatch(preMatch, ret);
if (!ar) break;
// do not replace any matches that occur inside a string literal.
if ((quoteCount%2) === 1) {
ret.append(ar[0]);
continue;
}
switch (ar[0]) {
case "dddd":
// Day of the week, using the full name
ret.append(dtf.DayNames[this.getDay()]);
break;
case "ddd":
//Day of the week, as a three-letter abbreviation
ret.append(dtf.AbbreviatedDayNames[this.getDay()]);
break;
case "dd":
// Day of month, with leading zero for single-digit days
ret.append(addLeadingZero(this.getDate()));
break;
case "d":
// Day of month, without leading zero for single-digit days
ret.append(this.getDate());
break;
case "MMMM":
// Month, using the full name
ret.append(dtf.MonthNames[this.getMonth()]);
break;
case "MMM":
// Month, as a three-letter abbreviation
ret.append(dtf.AbbreviatedMonthNames[this.getMonth()]);
break;
case "MM":
// Month, as digits, with leading zero for single-digit months
ret.append(addLeadingZero(this.getMonth() + 1));
break;
case "M":
// Month, as digits, with no leading zero for single-digit months
ret.append(this.getMonth() + 1);
break;
case "yyyy":
// Year represented by four full digits
ret.append(this.getFullYear());
break;
case "yy":
// Year, as two digits, with leading zero for years less than 10
ret.append(addLeadingZero(this.getFullYear() % 100));
break;
case "y":
// Year, as two digits, but with no leading zero for years less than 10
ret.append(this.getFullYear() % 100);
break;
case "hh":
// Hours with leading zero for single-digit hours, using 12-hour clock
hour = this.getHours() % 12;
if (hour === 0) hour = 12;
ret.append(addLeadingZero(hour));
break;
case "h":
// Hours with no leading zero for single-digit hours, using 12-hour clock
hour = this.getHours() % 12;
if (hour === 0) hour = 12;
ret.append(hour);
break;
case "HH":
// Hours with leading zero for single-digit hours, using 24-hour clock
ret.append(addLeadingZero(this.getHours()));
break;
case "H":
// Hours with no leading zero for single-digit hours, using 24-hour clock
ret.append(this.getHours());
break;
case "mm":
// Minutes with leading zero for single-digit minutes
ret.append(addLeadingZero(this.getMinutes()));
break;
case "m":
// Minutes with no leading zero for single-digit minutes
ret.append(this.getMinutes());
break;
case "ss":
// Seconds with leading zero for single-digit seconds
ret.append(addLeadingZero(this.getSeconds()));
break;
case "s":
// Seconds with no leading zero for single-digit seconds
ret.append(this.getSeconds());
break;
case "tt":
// Multicharacter am/pm indicator
ret.append((this.getHours() < 12) ? dtf.AMDesignator : dtf.PMDesignator);
break;
case "t":
// One character am/pm indicator ("a" or "p")
ret.append(((this.getHours() < 12) ? dtf.AMDesignator : dtf.PMDesignator).charAt(0));
break;
case "f":
// Deciseconds
ret.append(addLeadingZeros(this.getMilliseconds()).charAt(0));
break;
case "ff":
// Centiseconds
ret.append(addLeadingZeros(this.getMilliseconds()).substr(0, 2));
break;
case "fff":
// Milliseconds
ret.append(addLeadingZeros(this.getMilliseconds()));
break;
case "z":
// Time zone offset, no leading zero
hour = this.getTimezoneOffset() / 60;
ret.append(((hour <= 0) ? '+' : '-') + Math.floor(Math.abs(hour)));
break;
case "zz":
// Time zone offset with leading zero
hour = this.getTimezoneOffset() / 60;
ret.append(((hour <= 0) ? '+' : '-') + addLeadingZero(Math.floor(Math.abs(hour))));
break;
case "zzz":
// Time zone offset with leading zero
hour = this.getTimezoneOffset() / 60;
ret.append(((hour <= 0) ? '+' : '-') + addLeadingZero(Math.floor(Math.abs(hour))) +
dtf.TimeSeparator + addLeadingZero(Math.abs(this.getTimezoneOffset() % 60)));
break;
}
}
return ret.toString();
}
Number.__typeName = 'Number';
Number.__class = true;
Number.parseLocale = function Number$parseLocale(value) {
/// <summary locid="M:J#Number.parseLocale" />
/// <param name="value" type="String"></param>
/// <returns type="Number"></returns>
var e = Function._validateParams(arguments, [
{name: "value", type: String}
]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -