[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/template/lib/mootools/more-1.3/Types/ -> Date.js (source)

   1  (function(){var a=this.Date;var f=a.Methods={ms:"Milliseconds",year:"FullYear",min:"Minutes",mo:"Month",sec:"Seconds",hr:"Hours"};["Date","Day","FullYear","Hours","Milliseconds","Minutes","Month","Seconds","Time","TimezoneOffset","Week","Timezone","GMTOffset","DayOfYear","LastMonth","LastDayOfMonth","UTCDate","UTCDay","UTCFullYear","AMPM","Ordinal","UTCHours","UTCMilliseconds","UTCMinutes","UTCMonth","UTCSeconds","UTCMilliseconds"].each(function(t){a.Methods[t.toLowerCase()]=t});var p=function(v,u,t){if(u==1){return v}return v<Math.pow(10,u-1)?(t||"0")+p(v,u-1,t):v};a.implement({set:function(v,t){v=v.toLowerCase();var u=f[v]&&"set"+f[v];if(u&&this[u]){this[u](t)}return this}.overloadSetter(),get:function(u){u=u.toLowerCase();var t=f[u]&&"get"+f[u];if(t&&this[t]){return this[t]()}return null}.overloadGetter(),clone:function(){return new a(this.get("time"))},increment:function(t,v){t=t||"day";v=v!=null?v:1;switch(t){case"year":return this.increment("month",v*12);case"month":var u=this.get("date");this.set("date",1).set("mo",this.get("mo")+v);return this.set("date",u.min(this.get("lastdayofmonth")));case"week":return this.increment("day",v*7);case"day":return this.set("date",this.get("date")+v)}if(!a.units[t]){throw new Error(t+" is not a supported interval")}return this.set("time",this.get("time")+v*a.units[t]())},decrement:function(t,u){return this.increment(t,-1*(u!=null?u:1))},isLeapYear:function(){return a.isLeapYear(this.get("year"))},clearTime:function(){return this.set({hr:0,min:0,sec:0,ms:0})},diff:function(u,t){if(typeOf(u)=="string"){u=a.parse(u)}return((u-this)/a.units[t||"day"](3,3)).round()},getLastDayOfMonth:function(){return a.daysInMonth(this.get("mo"),this.get("year"))},getDayOfYear:function(){return(a.UTC(this.get("year"),this.get("mo"),this.get("date")+1)-a.UTC(this.get("year"),0,1))/a.units.day()},setDay:function(u,t){if(t==null){t=a.getMsg("firstDayOfWeek");if(t===""){t=1}}u=(7+a.parseDay(u,true)-t)%7;var v=(7+this.get("day")-t)%7;return this.increment("day",u-v)},getWeek:function(w){if(w==null){w=a.getMsg("firstDayOfWeek");if(w===""){w=1}}var y=this,v=(7+y.get("day")-w)%7,u=0,x;if(w==1){var z=y.get("month"),t=y.get("date")-v;if(z==11&&t>28){return 1}if(z==0&&t<-2){y=new a(y).decrement("day",v);v=0}x=new a(y.get("year"),0,1).get("day")||7;if(x>4){u=-7}}else{x=new a(y.get("year"),0,1).get("day")}u+=y.get("dayofyear");u+=6-v;u+=(7+x-w)%7;return(u/7)},getOrdinal:function(t){return a.getMsg("ordinal",t||this.get("date"))},getTimezone:function(){return this.toString().replace(/^.*? ([A-Z]{3}).[0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3")},getGMTOffset:function(){var t=this.get("timezoneOffset");return((t>0)?"-":"+")+p((t.abs()/60).floor(),2)+p(t%60,2)},setAMPM:function(t){t=t.toUpperCase();var u=this.get("hr");if(u>11&&t=="AM"){return this.decrement("hour",12)}else{if(u<12&&t=="PM"){return this.increment("hour",12)}}return this},getAMPM:function(){return(this.get("hr")<12)?"AM":"PM"},parse:function(t){this.set("time",a.parse(t));return this},isValid:function(t){return !isNaN((t||this).valueOf())},format:function(u){if(!this.isValid()){return"invalid date"}if(!u){u="%x %X"}var t=u.toLowerCase();if(s[t]){return s[t](this)}u=g[t]||u;var v=this;return u.replace(/%([a-z%])/gi,function(x,w){switch(w){case"a":return a.getMsg("days_abbr")[v.get("day")];case"A":return a.getMsg("days")[v.get("day")];case"b":return a.getMsg("months_abbr")[v.get("month")];case"B":return a.getMsg("months")[v.get("month")];case"c":return v.format("%a %b %d %H:%M:%S %Y");case"d":return p(v.get("date"),2);case"e":return p(v.get("date"),2," ");case"H":return p(v.get("hr"),2);case"I":return p((v.get("hr")%12)||12,2);case"j":return p(v.get("dayofyear"),3);case"k":return p(v.get("hr"),2," ");case"l":return p((v.get("hr")%12)||12,2," ");case"L":return p(v.get("ms"),3);case"m":return p((v.get("mo")+1),2);case"M":return p(v.get("min"),2);case"o":return v.get("ordinal");case"p":return a.getMsg(v.get("ampm"));case"s":return Math.round(v/1000);case"S":return p(v.get("seconds"),2);case"T":return v.format("%H:%M:%S");case"U":return p(v.get("week"),2);case"w":return v.get("day");case"x":return v.format(a.getMsg("shortDate"));case"X":return v.format(a.getMsg("shortTime"));case"y":return v.get("year").toString().substr(2);case"Y":return v.get("year");case"z":return v.get("GMTOffset");case"Z":return v.get("Timezone")}return w})},toISOString:function(){return this.format("iso8601")}}).alias({toJSON:"toISOString",compare:"diff",strftime:"format"});var g={db:"%Y-%m-%d %H:%M:%S",compact:"%Y%m%dT%H%M%S","short":"%d %b %H:%M","long":"%B %d, %Y %H:%M"};var k=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var s={rfc822:function(t){return k[t.get("day")]+t.format(", %d ")+h[t.get("month")]+t.format(" %Y %H:%M:%S %Z")},rfc2822:function(t){return k[t.get("day")]+t.format(", %d ")+h[t.get("month")]+t.format(" %Y %H:%M:%S %z")},iso8601:function(t){return(t.getUTCFullYear()+"-"+p(t.getUTCMonth()+1,2)+"-"+p(t.getUTCDate(),2)+"T"+p(t.getUTCHours(),2)+":"+p(t.getUTCMinutes(),2)+":"+p(t.getUTCSeconds(),2)+"."+p(t.getUTCMilliseconds(),3)+"Z")}};var c=[],n=a.parse;var r=function(w,y,v){var u=-1,x=a.getMsg(w+"s");switch(typeOf(y)){case"object":u=x[y.get(w)];break;case"number":u=x[y];if(!u){throw new Error("Invalid "+w+" index: "+y)}break;case"string":var t=x.filter(function(z){return this.test(z)},new RegExp("^"+y,"i"));if(!t.length){throw new Error("Invalid "+w+" string")}if(t.length>1){throw new Error("Ambiguous "+w)}u=t[0]}return(v)?x.indexOf(u):u};var i=1900,o=70;a.extend({getMsg:function(u,t){return Locale.get("Date."+u,t)},units:{ms:Function.from(1),second:Function.from(1000),minute:Function.from(60000),hour:Function.from(3600000),day:Function.from(86400000),week:Function.from(608400000),month:function(u,t){var v=new a;return a.daysInMonth(u!=null?u:v.get("mo"),t!=null?t:v.get("year"))*86400000},year:function(t){t=t||new a().get("year");return a.isLeapYear(t)?31622400000:31536000000}},daysInMonth:function(u,t){return[31,a.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][u]},isLeapYear:function(t){return((t%4===0)&&(t%100!==0))||(t%400===0)},parse:function(w){var v=typeOf(w);if(v=="number"){return new a(w)}if(v!="string"){return w}w=w.clean();if(!w.length){return null}var u;c.some(function(x){var t=x.re.exec(w);return(t)?(u=x.handler(t)):false});if(!(u&&u.isValid())){u=new a(n(w));if(!(u&&u.isValid())){u=new a(w.toInt())}}return u},parseDay:function(t,u){return r("day",t,u)},parseMonth:function(u,t){return r("month",u,t)},parseUTC:function(u){var t=new a(u);var v=a.UTC(t.get("year"),t.get("mo"),t.get("date"),t.get("hr"),t.get("min"),t.get("sec"),t.get("ms"));return new a(v)},orderIndex:function(t){return a.getMsg("dateOrder").indexOf(t)+1},defineFormat:function(t,u){g[t]=u;return this},defineFormats:function(t){for(var u in t){a.defineFormat(u,t[u])}return this},parsePatterns:c,defineParser:function(t){c.push((t.re&&t.handler)?t:l(t));return this},defineParsers:function(){Array.flatten(arguments).each(a.defineParser);return this},define2DigitYearStart:function(t){o=t%100;i=t-o;return this}});var d=function(t){return new RegExp("(?:"+a.getMsg(t).map(function(u){return u.substr(0,3)}).join("|")+")[a-z]*")};var m=function(t){switch(t){case"T":return"%H:%M:%S";case"x":return((a.orderIndex("month")==1)?"%m[-./]%d":"%d[-./]%m")+"([-./]%y)?";case"X":return"%H([.:]%M)?([.:]%S([.:]%s)?)? ?%p? ?%z?"}return null};var j={d:/[0-2]?[0-9]|3[01]/,H:/[01]?[0-9]|2[0-3]/,I:/0?[1-9]|1[0-2]/,M:/[0-5]?\d/,s:/\d+/,o:/[a-z]*/,p:/[ap]\.?m\.?/,y:/\d{2}|\d{4}/,Y:/\d{4}/,z:/Z|[+-]\d{2}(?::?\d{2})?/};j.m=j.I;j.S=j.M;var e;var b=function(t){e=t;j.a=j.A=d("days");j.b=j.B=d("months");c.each(function(v,u){if(v.format){c[u]=l(v.format)}})};var l=function(v){if(!e){return{format:v}}var t=[];var u=(v.source||v).replace(/%([a-z])/gi,function(x,w){return m(w)||x}).replace(/\((?!\?)/g,"(?:").replace(/ (?!\?|\*)/g,",? ").replace(/%([a-z%])/gi,function(x,w){var y=j[w];if(!y){return w}t.push(w);return"("+y.source+")"}).replace(/\[a-z\]/gi,"[a-z\\u00c0-\\uffff;&]");return{format:v,re:new RegExp("^"+u+"$","i"),handler:function(z){z=z.slice(1).associate(t);var w=new a().clearTime(),y=z.y||z.Y;if(y!=null){q.call(w,"y",y)}if("d" in z){q.call(w,"d",1)}if("m" in z||z.b||z.B){q.call(w,"m",1)}for(var x in z){q.call(w,x,z[x])}return w}}};var q=function(t,u){if(!u){return this}switch(t){case"a":case"A":return this.set("day",a.parseDay(u,true));case"b":case"B":return this.set("mo",a.parseMonth(u,true));case"d":return this.set("date",u);case"H":case"I":return this.set("hr",u);case"m":return this.set("mo",u-1);case"M":return this.set("min",u);case"p":return this.set("ampm",u.replace(/\./g,""));case"S":return this.set("sec",u);case"s":return this.set("ms",("0."+u)*1000);case"w":return this.set("day",u);case"Y":return this.set("year",u);case"y":u=+u;if(u<100){u+=i+(u<o?100:0)}return this.set("year",u);case"z":if(u=="Z"){u="+00"}var v=u.match(/([+-])(\d{2}):?(\d{2})?/);v=(v[1]+"1")*(v[2]*60+(+v[3]||0))+this.getTimezoneOffset();return this.set("time",this-v*60000)}return this};a.defineParsers("%Y([-./]%m([-./]%d((T| )%X)?)?)?","%Y%m%d(T%H(%M%S?)?)?","%x( %X)?","%d%o( %b( %Y)?)?( %X)?","%b( %d%o)?( %Y)?( %X)?","%Y %b( %d%o( %X)?)?","%o %b %d %X %z %Y","%T","%H:%M( ?%p)?");Locale.addEvent("change",function(t){if(Locale.get("Date")){b(t)}}).fireEvent("change",Locale.getCurrent())})();


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1