Newtouch.Date = function(settings){
	this._date = settings.date;
	this._format = settings.format;
};

Newtouch.Date.prototype = {
	_date:null,
	_format:null,//'YYYY-MM-DD hh:mm:ss'
	
	format:function(){
		var o = {
			"M+" : this._date.getMonth()+1, //month
			
			"D+" : this._date.getDate(), //day
			
			"h+" : this._date.getHours(), //hour
			
			"m+" : this._date.getMinutes(), //minute
			
			"s+" : this._date.getSeconds(), //second
			
			"q+" : Math.floor((this._date.getMonth()+3)/3), //quarter
			
			"S" : this._date.getMilliseconds() //millisecond
		}
		if(/(Y+)/.test(this._format))
			this._format=this._format.replace(RegExp.$1,(this._date.getFullYear()+"").substr(4 - RegExp.$1.length));
		for(var k in o){
			if(new RegExp("("+ k +")").test(this._format)){
				this._format = this._format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length));
			}
		}
		return this._format;
	}
}
