/*
--------------------------------------------------------
dateformat.js - Simple date formatter
Version 1.1 (Update 2008/04/02)

Copyright (c) 2007-2008 onozaty (http://www.enjoyxstudy.com)

Released under an MIT-style license.

For details, see the web site:
 http://www.enjoyxstudy.com/javascript/dateformat/

--------------------------------------------------------
*/
var DateFormat=function(A){this._init(A)};DateFormat.prototype={_init:function(D){this.pattern=D;this._patterns=[];for(var B=0;B<D.length;B++){var C=D.charAt(B);if(this._patterns.length==0){this._patterns[0]=C}else{var A=this._patterns.length-1;if(this._patterns[A].charAt(0)=="'"){if(this._patterns[A].length==1||this._patterns[A].charAt(this._patterns[A].length-1)!="'"){this._patterns[A]+=C}else{this._patterns[A+1]=C}}else{if(this._patterns[A].charAt(0)==C){this._patterns[A]+=C}else{this._patterns[A+1]=C}}}}},format:function(B){var A=[];for(var C=0;C<this._patterns.length;C++){A[C]=this._formatWord(B,this._patterns[C])}return A.join("")},_formatWord:function(A,C){var B=this._formatter[C.charAt(0)];if(B){return B.apply(this,[A,C])}else{return C}},_formatter:{y:function(A,C){var B=String(A.getFullYear());if(C.length<=2){B=B.substring(2,4)}else{B=this._zeroPadding(B,C.length)}return B},M:function(A,B){return this._zeroPadding(String(A.getMonth()+1),B.length)},d:function(A,B){return this._zeroPadding(String(A.getDate()),B.length)},H:function(A,B){return this._zeroPadding(String(A.getHours()),B.length)},m:function(A,B){return this._zeroPadding(String(A.getMinutes()),B.length)},s:function(A,B){return this._zeroPadding(String(A.getSeconds()),B.length)},S:function(A,B){return this._zeroPadding(String(A.getMilliseconds()),B.length)},"'":function(A,B){if(B=="''"){return"'"}else{return B.replace(/'/g,"")}}},_zeroPadding:function(B,A){if(B.length>=A){return B}return new Array(A-B.length+1).join("0")+B},parse:function(C){if(typeof C!="string"||C==""){return null}var A={year:1970,month:1,day:1,hour:0,min:0,sec:0,msec:0};for(var B=0;B<this._patterns.length;B++){if(C==""){return null}C=this._parseWord(C,this._patterns[B],A);if(C===null){return null}}if(C!=""){return null}return new Date(A.year,A.month-1,A.day,A.hour,A.min,A.sec,A.msec)},_parseWord:function(C,B,A){var D=this._parser[B.charAt(0)];if(D){return D.apply(this,[C,B,A])}else{if(C.indexOf(B)!=0){return null}else{return C.substring(B.length)}}},_parser:{y:function(E,D,A){var B;if(D.length<=2){B=E.substring(0,2);B=B<70?"20"+B:"19"+B;E=E.substring(2)}else{var C=(D.length==3)?4:D.length;B=E.substring(0,C);E=E.substring(C)}if(!this._isNumber(B)){return null}A.year=parseInt(B,10);return E},M:function(D,B,A){var C;if(B.length==1&&D.length>1&&D.substring(0,2).match(/1[0-2]/)!=null){C=D.substring(0,2);D=D.substring(2)}else{C=D.substring(0,B.length);D=D.substring(B.length)}if(!this._isNumber(C)){return null}A.month=parseInt(C,10);return D},d:function(D,C,A){var B;if(C.length==1&&D.length>1&&D.substring(0,2).match(/1[0-9]|2[0-9]|3[0-1]/)!=null){B=D.substring(0,2);D=D.substring(2)}else{B=D.substring(0,C.length);D=D.substring(C.length)}if(!this._isNumber(B)){return null}A.day=parseInt(B,10);return D},H:function(D,C,A){var B;if(C.length==1&&D.length>1&&D.substring(0,2).match(/1[0-9]|2[0-3]/)!=null){B=D.substring(0,2);D=D.substring(2)}else{B=D.substring(0,C.length);D=D.substring(C.length)}if(!this._isNumber(B)){return null}A.hour=parseInt(B,10);return D},m:function(D,C,A){var B;if(C.length==1&&D.length>1&&D.substring(0,2).match(/[1-5][0-9]/)!=null){B=D.substring(0,2);D=D.substring(2)}else{B=D.substring(0,C.length);D=D.substring(C.length)}if(!this._isNumber(B)){return null}A.min=parseInt(B,10);return D},s:function(D,C,A){var B;if(C.length==1&&D.length>1&&D.substring(0,2).match(/[1-5][0-9]/)!=null){B=D.substring(0,2);D=D.substring(2)}else{B=D.substring(0,C.length);D=D.substring(C.length)}if(!this._isNumber(B)){return null}A.sec=parseInt(B,10);return D},S:function(D,B,A){var C;if(B.length==1||B.length==2){if(D.length>2&&D.substring(0,3).match(/[1-9][0-9][0-9]/)!=null){C=D.substring(0,3);D=D.substring(3)}else{if(D.length>1&&D.substring(0,2).match(/[1-9][0-9]/)!=null){C=D.substring(0,2);D=D.substring(2)}else{C=D.substring(0,B.length);D=D.substring(B.length)}}}else{C=D.substring(0,B.length);D=D.substring(B.length)}if(!this._isNumber(C)){return null}A.msec=parseInt(C,10);return D},"'":function(C,B,A){if(B=="''"){B="'"}else{B=B.replace(/'/g,"")}if(C.indexOf(B)!=0){return null}else{return C.substring(B.length)}}},_isNumber:function(A){return/^[0-9]*$/.test(A)}};
