[ Index ]

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

title

Body

[close]

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

   1  Date.implement({timeDiffInWords:function(a){return Date.distanceOfTimeInWords(this,a||new Date)},timeDiff:function(f,c){if(f==null){f=new Date}var h=((f-this)/1000).floor().abs();var e=[],a=[60,60,24,365,0],d=["s","m","h","d","y"],g,b;for(var i=0;i<a.length;i++){if(i&&!h){break}g=h;if((b=a[i])){g=(h%b);h=(h/b).floor()}e.unshift(g+(d[i]||""))}return e.join(c||":")}}).extend({distanceOfTimeInWords:function(b,a){return Date.getTimePhrase(((a-b)/1000).toInt())},getTimePhrase:function(f){var d=(f<0)?"Until":"Ago";if(f<0){f*=-1}var b={minute:60,hour:60,day:24,week:7,month:52/12,year:12,eon:Infinity};var e="lessThanMinute";for(var c in b){var a=b[c];if(f<1.5*a){if(f>0.75*a){e=c}break}f/=a;e=c+"s"}f=f.round();return Date.getMsg(e+d,f).substitute({delta:f})}}).defineParsers({re:/^(?:tod|tom|yes)/i,handler:function(a){var b=new Date().clearTime();switch(a[0]){case"tom":return b.increment();case"yes":return b.decrement();default:return b}}},{re:/^(next|last) ([a-z]+)$/i,handler:function(e){var f=new Date().clearTime();var b=f.getDay();var c=Date.parseDay(e[2],true);var a=c-b;if(c<=b){a+=7}if(e[1]=="last"){a-=7}return f.set("date",f.getDate()+a)}}).alias("timeAgoInWords","timeDiffInWords");


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