⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 date-min.js

📁 ext js demo ext学习资料
💻 JS
字号:
/*
 * Ext JS Library 1.1 RC 1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(_1){if(Date.formatFunctions[_1]==null){Date.createNewFormat(_1);}var _2=Date.formatFunctions[_1];return this[_2]();};Date.prototype.format=Date.prototype.dateFormat;Date.createNewFormat=function(_3){var _4="format"+Date.formatFunctions.count++;Date.formatFunctions[_3]=_4;var _5="Date.prototype."+_4+" = function(){return ";var _6=false;var ch="";for(var i=0;i<_3.length;++i){ch=_3.charAt(i);if(!_6&&ch=="\\"){_6=true;}else{if(_6){_6=false;_5+="'"+String.escape(ch)+"' + ";}else{_5+=Date.getFormatCode(ch);}}}eval(_5.substring(0,_5.length-3)+";}");};Date.getFormatCode=function(_9){switch(_9){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(_9)+"' + ";}};Date.parseDate=function(_a,_b){if(Date.parseFunctions[_b]==null){Date.createParser(_b);}var _c=Date.parseFunctions[_b];return Date[_c](_a);};Date.createParser=function(_d){var _e="parse"+Date.parseFunctions.count++;var _f=Date.parseRegexes.length;var _10=1;Date.parseFunctions[_d]=_e;var _11="Date."+_e+" = function(input){\n"+"var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, o, z;\n"+"var d = new Date();\n"+"y = d.getFullYear();\n"+"m = d.getMonth();\n"+"d = d.getDate();\n"+"var v = null, results = input.match(Date.parseRegexes["+_f+"]);\n"+"if (results && results.length > 0) {";var _12="";var _13=false;var ch="";for(var i=0;i<_d.length;++i){ch=_d.charAt(i);if(!_13&&ch=="\\"){_13=true;}else{if(_13){_13=false;_12+=String.escape(ch);}else{var obj=Date.formatCodeToRegex(ch,_10);_10+=obj.g;_12+=obj.s;if(obj.g&&obj.c){_11+=obj.c;}}}}_11+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"+"{v = new Date(y, m, d, h, i, s);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"+"{v = new Date(y, m, d, h, i);}\n"+"else if (y > 0 && m >= 0 && d > 0 && h >= 0)\n"+"{v = new Date(y, m, d, h);}\n"+"else if (y > 0 && m >= 0 && d > 0)\n"+"{v = new Date(y, m, d);}\n"+"else if (y > 0 && m >= 0)\n"+"{v = new Date(y, m);}\n"+"else if (y > 0)\n"+"{v = new Date(y);}\n"+"}return (v && (z || o))?\n"+"    ((z)? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :\n"+"        v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : v\n"+";}";Date.parseRegexes[_f]=new RegExp("^"+_12+"$");eval(_11);};Date.formatCodeToRegex=function(_17,_18){switch(_17){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+_18+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:0,c:null,s:"(?:\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+_18+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+_18+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+_18+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+_18+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+_18+"], 10);\n"+"y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+_18+"] == 'am') {\n"+"if (h == 12) { h = 0; }\n"+"} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+_18+"] == 'AM') {\n"+"if (h == 12) { h = 0; }\n"+"} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+_18+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+_18+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+_18+"], 10);\n",s:"(\\d{2})"};case"O":return{g:1,c:["o = results[",_18,"];\n","var sn = o.substring(0,1);\n","var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);\n","var mn = o.substring(3,5) % 60;\n","o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n","    (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n"].join(""),s:"([+-]\\d{4})"};case"T":return{g:0,c:null,s:"[A-Z]{1,4}"};case"Z":return{g:1,c:"z = results["+_18+"];\n"+"z = (-43200 <= z*1 && z*1 <= 50400)? z : null;\n",s:"([+-]?\\d{1,5})"};default:return{g:0,c:null,s:String.escape(_17)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{1,4})[\-+][0-9]{4} .*$/,"$1");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset()/60)),2,"0")+String.leftPad(this.getTimezoneOffset()%60,2,"0");};Date.prototype.getDayOfYear=function(){var num=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var i=0;i<this.getMonth();++i){num+=Date.daysInMonth[i];}return num+this.getDate()-1;};Date.prototype.getWeekOfYear=function(){var now=this.getDayOfYear()+(4-this.getDay());var _1c=new Date(this.getFullYear(),0,1);var _1d=(7-_1c.getDay()+4);return String.leftPad(((now-_1d)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var _1e=this.getFullYear();return((_1e&3)==0&&(_1e%100||(_1e%400==0&&_1e)));};Date.prototype.getFirstDayOfMonth=function(){var day=(this.getDay()-(this.getDate()-1))%7;return(day<0)?(day+7):day;};Date.prototype.getLastDayOfMonth=function(){var day=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(day<0)?(day+7):day;};Date.prototype.getFirstDateOfMonth=function(){return new Date(this.getFullYear(),this.getMonth(),1);};Date.prototype.getLastDateOfMonth=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDaysInMonth());};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.prototype.clone=function(){return new Date(this.getTime());};Date.prototype.clearTime=function(_21){if(_21){return this.clone().clearTime();}this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};if(Ext.isSafari){Date.brokenSetMonth=Date.prototype.setMonth;Date.prototype.setMonth=function(num){if(num<=-1){var n=Math.ceil(-num);var _24=Math.ceil(n/12);var _25=(n%12)?12-n%12:0;this.setFullYear(this.getFullYear()-_24);return Date.brokenSetMonth.call(this,_25);}else{return Date.brokenSetMonth.apply(this,arguments);}};}Date.MILLI="ms";Date.SECOND="s";Date.MINUTE="mi";Date.HOUR="h";Date.DAY="d";Date.MONTH="mo";Date.YEAR="y";Date.prototype.add=function(_26,_27){var d=this.clone();if(!_26||_27===0){return d;}switch(_26.toLowerCase()){case Date.MILLI:d.setMilliseconds(this.getMilliseconds()+_27);break;case Date.SECOND:d.setSeconds(this.getSeconds()+_27);break;case Date.MINUTE:d.setMinutes(this.getMinutes()+_27);break;case Date.HOUR:d.setHours(this.getHours()+_27);break;case Date.DAY:d.setDate(this.getDate()+_27);break;case Date.MONTH:var day=this.getDate();if(day>28){day=Math.min(day,this.getFirstDateOfMonth().add("mo",_27).getLastDateOfMonth().getDate());}d.setDate(day);d.setMonth(this.getMonth()+_27);break;case Date.YEAR:d.setFullYear(this.getFullYear()+_27);break;}return d;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -