// ------------------------------- date object ----------------------------------------
function myDate(dateStr) {
   if (dateStr==undefined) var dateStr="";
   this.date=dateStr;
   
   // methods
   this.shortDate=shortDate;
   this.dateNumber=dateNumber;
   this.reportDate=reportDate;
   this.solveDate=solveDate;
   this.convertToJavascriptDate=convertToJavascriptDate;
   
   // method functions
   function shortDate() {
      // d.m
   }
   
   function convertToJavascriptDate() {
      var month=parseInt(this.date.slice(5,7),10)-1;
      var day=parseInt(this.date.slice(8,10),10);
      var year=parseInt(this.date.slice(0,4),10);
      var hour=parseInt(this.date.slice(11,13),10);
      if (this.date.slice(-1)!="*") hour+=2;
      var mins=parseInt(this.date.slice(14,16),10);
      var secs=0; // -----------------------------------------------
      
      var d=new Date();
      d.setFullYear(year,month,day);
      d.setHours(hour,mins);
      return d;
   }
   
   function solveDate() {
      // DAY, d MMM yyyy, tt:tt
      var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
      var month=parseInt(this.date.slice(5,7),10)-1;
      var day=parseInt(this.date.slice(8,10),10);
      var year=parseInt(this.date.slice(0,4),10);
      var hour=parseInt(this.date.slice(11,13),10);
      if (this.date.slice(-1)!="*") hour+=2;
      var mins=parseInt(this.date.slice(14,16),10);
      var hourStr="0"+hour;
      var minsStr="0"+mins;
      return _getWeekDayFromDate(day,month,year,hour,mins)+", "+day+" "+months[month]+" "+year+", "+hourStr.slice(-2)+":"+minsStr.slice(-2);
   }
   
   function reportDate() {
      // d MMM
      var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
      var month=parseInt(this.date.slice(5,7),10);
      var day=parseInt(this.date.slice(8,10),10);
      return day+" "+months[month-1];
   }
   
   function dateNumber() {
      // yymmddhhmmss (?)
      var year=parseInt(this.date.slice(2,4),10);
      var day=parseInt(this.date.slice(8,10),10);
      var month=parseInt(this.date.slice(5,7),10);
      var callStr=this.date.slice(11,13)+this.date.slice(14,16)+this.date.slice(17,19);
      var callTime=parseInt(callStr,10);
      return 10000000000*year+100000000*month+1000000*day+callTime;
   }
}

function _getWeekDayFromDate(day,month,year,hour,mins) {
   var weekday=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
   var d = new Date(year, month, day, hour, mins, 0, 0); 
   return weekday[d.getDay()]; 
}