//version:1.0
//author: BrianChao
//locale : taiwan

function DateUtil(valueA){
 //***********************************property****************************************************
this.pattern = "yyyy/MM/dd";
this.value = valueA;
//*************************************method***************************************************
 this.getTime     = JFunc_getTime;
 this.getYear     = JFunc_getYear;
 this.getMonth    = JFunc_getMonth;
 this.getDay      = JFunc_getDay;
 this.getHours    = JFunc_getHours;
 this.getMinutes  = JFunc_getMinutes;
 this.setFormat   = JFunc_setFormat;
}

function JFunc_setFormat(patternA){
  this.pattern = patternA;
}

function JFunc_getDate(pattern,value){
   var cDate = null;
   if(pattern=="yyyy/MM/dd hh:mm"){
     var Temp =  value.split(" ");
     var Temp1 = Temp[0].split("/");
     var Temp2 = Temp[1].split(":");
     //dateObjectName = new Date(year, month, day, hours, minutes, seconds)

     cDate = new Date(Temp1[0],(eval(Temp1[1]) - 1),Temp1[2],Temp2[0],Temp2[1],0);
   }
   else{
     var Temp1 =  value.split("/");
     cDate = new Date(Temp1[0],(eval(Temp1[1]) - 1),Temp1[2]);
   }
   return cDate;
}

function JFunc_getTime(){
   var date = JFunc_getDate(this.pattern,this.value);
   return date.getTime();
}

function JFunc_getYear(){
   var date = JFunc_getDate(this.pattern,this.value);
   return date.getYear();
}

function JFunc_getMonth(){
   var date = JFunc_getDate(this.pattern,this.value);
   return eval(date.getMonth()+1);
}

function JFunc_getDay(){
   var date = JFunc_getDate(this.pattern,this.value);
   return date.getDate();
}

function JFunc_getHours(){
   var date = JFunc_getDate(this.pattern,this.value);
   return date.getHours();
}

function JFunc_getMinutes(){
   var date = JFunc_getDate(this.pattern,this.value);
   return date.getMinutes();
}
