/**
 * jDate Plugin for jQuery
 * @author: Michael Gilley <michael@180bydesign.com>
 * @site: www.180bydesign.com
 * @version: 1.0
 * @date: April 1, 2010
 * @dependencies: jQuery 1.3+
 * 
 * DESCRIPTION
 * This is a simple jQuery plugin that is basically just a wrapper 
 * for Php.js's date() function (http://phpjs.org/functions/date:380). 
 * I'm indebted to the good people listed below for most of this 
 * great code.
 * 
 * USAGE
 * Provided are both a jQuery function that returns a formatted 
 * date string and a jQuery method that inserts the string into any
 * matched elements as text. For further instructions see php's 
 * documentation on the function at 
 * http://php.net/manual/en/function.date.php.
 * 
 * EXAMPLES
 * $.date('F j, Y \\a\\t g:i:sa');  =>  January 1, 1970 at 12:00am
 * $('.date').date('Y-m-d H:i:s');  => <div class="date">1970-01-01 12:00:00</div>
 */
(function($){$.date=function(e,g){var h=this,jsdate,f,formatChr=/\\?([a-z])/gi,formatChrCb,_pad=function(n,c){if((n=n+"").length<c){return new Array((++c)-n.length).join("0")+n}else{return n}},txt_words=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur","January","February","March","April","May","June","July","August","September","October","November","December"],txt_ordin={1:"st",2:"nd",3:"rd",21:"st",22:"nd",23:"rd",31:"st"};formatChrCb=function(t,s){return f[t]?f[t]():s};f={d:function(){return _pad(f.j(),2)},D:function(){return f.l().slice(0,3)},j:function(){return jsdate.getDate()},l:function(){return txt_words[f.w()]+'day'},N:function(){return f.w()||7},S:function(){return txt_ordin[f.j()]||'th'},w:function(){return jsdate.getDay()},z:function(){var a=new Date(f.Y(),f.n()-1,f.j()),b=new Date(f.Y(),0,1);return Math.round((a-b)/864e5)+1},W:function(){var a=new Date(f.Y(),f.n()-1,f.j()-f.N()+3),b=new Date(a.getFullYear(),0,4);return 1+Math.round((a-b)/864e5/7)},F:function(){return txt_words[6+f.n()]},m:function(){return _pad(f.n(),2)},M:function(){return f.F().slice(0,3)},n:function(){return jsdate.getMonth()+1},t:function(){return(new Date(f.Y(),f.n(),0)).getDate()},L:function(){var y=f.Y(),a=y&3,b=y%4e2,c=y%1e2;return 0+(!a&&(c||!b))},o:function(){var n=f.n(),W=f.W(),Y=f.Y();return Y+(n===12&&W<9?-1:n===1&&W>9)},Y:function(){return jsdate.getFullYear()},y:function(){return(f.Y()+"").slice(-2)},a:function(){return jsdate.getHours()>11?"pm":"am"},A:function(){return f.a().toUpperCase()},B:function(){var H=jsdate.getUTCHours()*36e2,i=jsdate.getUTCMinutes()*60,s=jsdate.getUTCSeconds();return _pad(Math.floor((H+i+s+36e2)/86.4)%1e3,3)},g:function(){return f.G()%12||12},G:function(){return jsdate.getHours()},h:function(){return _pad(f.g(),2)},H:function(){return _pad(f.G(),2)},i:function(){return _pad(jsdate.getMinutes(),2)},s:function(){return _pad(jsdate.getSeconds(),2)},u:function(){return _pad(jsdate.getMilliseconds()*1000,6)},e:function(){return'UTC'},I:function(){var a=new Date(f.Y(),0),c=Date.UTC(f.Y(),0),b=new Date(f.Y(),6),d=Date.UTC(f.Y(),6);return 0+((a-c)!==(b-d))},O:function(){var a=jsdate.getTimezoneOffset();return(a>0?"-":"+")+_pad(Math.abs(a/60*100),4)},P:function(){var O=f.O();return(O.substr(0,3)+":"+O.substr(3,2))},T:function(){return'UTC'},Z:function(){return-jsdate.getTimezoneOffset()*60},c:function(){return'Y-m-d\\Th:i:sP'.replace(formatChr,formatChrCb)},r:function(){return'D, d M Y H:i:s O'.replace(formatChr,formatChrCb)},U:function(){return Math.round(jsdate.getTime()/1000)}};this.date=function(a,b){h=this;jsdate=((typeof b==='undefined')?new Date():(b instanceof Date)?new Date(b):new Date(b*1000));return a.replace(formatChr,formatChrCb)};return this.date(e,g)};$.fn.date=function(a,b){return this.text($.date(a,b))}})(jQuery);
