[ Index ]

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

title

Body

[close]

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

   1  (function(){var i=this.Date;if(!i.now){i.now=$time}i.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(p){i.Methods[p.toLowerCase()]=p});var d=function(q,p){return new Array(p-String(q).length+1).join("0")+q};i.implement({set:function(t,r){switch($type(t)){case"object":for(var s in t){this.set(s,t[s])}break;case"string":t=t.toLowerCase();var q=i.Methods;if(q[t]){this["set"+q[t]](r)}}return this},get:function(q){q=q.toLowerCase();var p=i.Methods;if(p[q]){return this["get"+p[q]]()}return null},clone:function(){return new i(this.get("time"))},increment:function(p,r){p=p||"day";r=$pick(r,1);switch(p){case"year":return this.increment("month",r*12);case"month":var q=this.get("date");this.set("date",1).set("mo",this.get("mo")+r);return this.set("date",q.min(this.get("lastdayofmonth")));case"week":return this.increment("day",r*7);case"day":return this.set("date",this.get("date")+r)}if(!i.units[p]){throw new Error(p+" is not a supported interval")}return this.set("time",this.get("time")+r*i.units[p]())},decrement:function(p,q){return this.increment(p,-1*$pick(q,1))},isLeapYear:function(){return i.isLeapYear(this.get("year"))},clearTime:function(){return this.set({hr:0,min:0,sec:0,ms:0})},diff:function(q,p){if($type(q)=="string"){q=i.parse(q)}return((q-this)/i.units[p||"day"](3,3)).round()},getLastDayOfMonth:function(){return i.daysInMonth(this.get("mo"),this.get("year"))},getDayOfYear:function(){return(i.UTC(this.get("year"),this.get("mo"),this.get("date")+1)-i.UTC(this.get("year"),0,1))/i.units.day()},getWeek:function(){return(this.get("dayofyear")/7).ceil()},getOrdinal:function(p){return i.getMsg("ordinal",p||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 p=this.get("timezoneOffset");return((p>0)?"-":"+")+d((p.abs()/60).floor(),2)+d(p%60,2)},setAMPM:function(p){p=p.toUpperCase();var q=this.get("hr");if(q>11&&p=="AM"){return this.decrement("hour",12)}else{if(q<12&&p=="PM"){return this.increment("hour",12)}}return this},getAMPM:function(){return(this.get("hr")<12)?"AM":"PM"},parse:function(p){this.set("time",i.parse(p));return this},isValid:function(p){return !isNaN((p||this).valueOf())},format:function(p){if(!this.isValid()){return"invalid date"}p=p||"%x %X";p=k[p.toLowerCase()]||p;var q=this;return p.replace(/%([a-z%])/gi,function(s,r){switch(r){case"a":return i.getMsg("days")[q.get("day")].substr(0,3);case"A":return i.getMsg("days")[q.get("day")];case"b":return i.getMsg("months")[q.get("month")].substr(0,3);case"B":return i.getMsg("months")[q.get("month")];case"c":return q.toString();case"d":return d(q.get("date"),2);case"D":return q.get("date");case"e":return q.get("date");case"H":return d(q.get("hr"),2);case"I":return((q.get("hr")%12)||12);case"j":return d(q.get("dayofyear"),3);case"m":return d((q.get("mo")+1),2);case"M":return d(q.get("min"),2);case"o":return q.get("ordinal");case"p":return i.getMsg(q.get("ampm"));case"s":return Math.round(q/1000);case"S":return d(q.get("seconds"),2);case"U":return d(q.get("week"),2);case"w":return q.get("day");case"x":return q.format(i.getMsg("shortDate"));case"X":return q.format(i.getMsg("shortTime"));case"y":return q.get("year").toString().substr(2);case"Y":return q.get("year");case"T":return q.get("GMTOffset");case"Z":return q.get("Timezone");case"z":return d(q.get("ms"),3)}return r})},toISOString:function(){return this.format("iso8601")}});i.alias("toISOString","toJSON");i.alias("diff","compare");i.alias("format","strftime");var k={db:"%Y-%m-%d %H:%M:%S",compact:"%Y%m%dT%H%M%S",iso8601:"%Y-%m-%dT%H:%M:%S%T",rfc822:"%a, %d %b %Y %H:%M:%S %Z","short":"%d %b %H:%M","long":"%B %d, %Y %H:%M"};var g=[];var e=i.parse;var n=function(s,u,r){var q=-1;var t=i.getMsg(s+"s");switch($type(u)){case"object":q=t[u.get(s)];break;case"number":q=t[u];if(!q){throw new Error("Invalid "+s+" index: "+u)}break;case"string":var p=t.filter(function(v){return this.test(v)},new RegExp("^"+u,"i"));if(!p.length){throw new Error("Invalid "+s+" string")}if(p.length>1){throw new Error("Ambiguous "+s)}q=p[0]}return(r)?t.indexOf(q):q};i.extend({getMsg:function(q,p){return MooTools.lang.get("Date",q,p)},units:{ms:$lambda(1),second:$lambda(1000),minute:$lambda(60000),hour:$lambda(3600000),day:$lambda(86400000),week:$lambda(608400000),month:function(q,p){var r=new i;return i.daysInMonth($pick(q,r.get("mo")),$pick(p,r.get("year")))*86400000},year:function(p){p=p||new i().get("year");return i.isLeapYear(p)?31622400000:31536000000}},daysInMonth:function(q,p){return[31,i.isLeapYear(p)?29:28,31,30,31,30,31,31,30,31,30,31][q]},isLeapYear:function(p){return((p%4===0)&&(p%100!==0))||(p%400===0)},parse:function(r){var q=$type(r);if(q=="number"){return new i(r)}if(q!="string"){return r}r=r.clean();if(!r.length){return null}var p;g.some(function(t){var s=t.re.exec(r);return(s)?(p=t.handler(s)):false});return p||new i(e(r))},parseDay:function(p,q){return n("day",p,q)},parseMonth:function(q,p){return n("month",q,p)},parseUTC:function(q){var p=new i(q);var r=i.UTC(p.get("year"),p.get("mo"),p.get("date"),p.get("hr"),p.get("min"),p.get("sec"),p.get("ms"));return new i(r)},orderIndex:function(p){return i.getMsg("dateOrder").indexOf(p)+1},defineFormat:function(p,q){k[p]=q},defineFormats:function(p){for(var q in p){i.defineFormat(q,p[q])}},parsePatterns:g,defineParser:function(p){g.push((p.re&&p.handler)?p:l(p))},defineParsers:function(){Array.flatten(arguments).each(i.defineParser)},define2DigitYearStart:function(p){h=p%100;m=p-h}});var m=1900;var h=70;var j=function(p){return new RegExp("(?:"+i.getMsg(p).map(function(q){return q.substr(0,3)}).join("|")+")[a-z]*")};var a=function(p){switch(p){case"x":return((i.orderIndex("month")==1)?"%m[-./]%d":"%d[-./]%m")+"([-./]%y)?";case"X":return"%H([.:]%M)?([.:]%S([.:]%s)?)? ?%p? ?%T?"}return null};var o={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}/,T:/Z|[+-]\d{2}(?::?\d{2})?/};o.m=o.I;o.S=o.M;var c;var b=function(p){c=p;o.a=o.A=j("days");o.b=o.B=j("months");g.each(function(r,q){if(r.format){g[q]=l(r.format)}})};var l=function(r){if(!c){return{format:r}}var p=[];var q=(r.source||r).replace(/%([a-z])/gi,function(t,s){return a(s)||t}).replace(/\((?!\?)/g,"(?:").replace(/ (?!\?|\*)/g,",? ").replace(/%([a-z%])/gi,function(t,s){var u=o[s];if(!u){return s}p.push(s);return"("+u.source+")"}).replace(/\[a-z\]/gi,"[a-z\\u00c0-\\uffff]");return{format:r,re:new RegExp("^"+q+"$","i"),handler:function(v){v=v.slice(1).associate(p);var s=new i().clearTime(),u=v.y||v.Y;if(u!=null){f.call(s,"y",u)}if("d" in v){f.call(s,"d",1)}if("m" in v||"b" in v||"B" in v){f.call(s,"m",1)}for(var t in v){f.call(s,t,v[t])}return s}}};var f=function(p,q){if(!q){return this}switch(p){case"a":case"A":return this.set("day",i.parseDay(q,true));case"b":case"B":return this.set("mo",i.parseMonth(q,true));case"d":return this.set("date",q);case"H":case"I":return this.set("hr",q);case"m":return this.set("mo",q-1);case"M":return this.set("min",q);case"p":return this.set("ampm",q.replace(/\./g,""));case"S":return this.set("sec",q);case"s":return this.set("ms",("0."+q)*1000);case"w":return this.set("day",q);case"Y":return this.set("year",q);case"y":q=+q;if(q<100){q+=m+(q<h?100:0)}return this.set("year",q);case"T":if(q=="Z"){q="+00"}var r=q.match(/([+-])(\d{2}):?(\d{2})?/);r=(r[1]+"1")*(r[2]*60+(+r[3]||0))+this.getTimezoneOffset();return this.set("time",this-r*60000)}return this};i.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 %T %Y");MooTools.lang.addEvent("langChange",function(p){if(MooTools.lang.get("Date")){b(p)}}).fireEvent("langChange",MooTools.lang.getCurrentLanguage())})();


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