// libDateExtension 2.1 - UF 2009-07-02

Date.OneDay=1000*60*60*24;
Date.prototype.GetFutureDate = GetFutureDate;		// Parameter: Anzahl Tage in der Zukunft
Date.prototype.GetFutureMonth = GetFutureMonth;
Date.prototype.strdate = strdate;			// Parameter: Format-String, z.B. %d.%m.%Y
Date.prototype.GetDaysInMonth = GetDaysInMonth;         // Gibt die Anzahl an Tagen im Monat des Datums-Objekts zurück

Date.arrMonth=['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];
Date.arrMonthShort=['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'];

function GetFutureDate () {

  if (!GetFutureDate.arguments.length) return (this);
  if (parseInt (GetFutureDate.arguments[0])==Number.NaN) return (this);

  var retValue=new Date (this);

  retValue.setTime (parseInt (Date.OneDay*GetFutureDate.arguments[0])+this.getTime ());

  return (retValue);
}

function GetFutureMonth () {

  if (!GetFutureMonth.arguments.length) return (this);
  if (parseInt (GetFutureMonth.arguments[0])==Number.NaN) return (this);

  var retValue=new Date (this);
  
  var intMonth=retValue.getUTCMonth ();
  intMonth+=GetFutureMonth.arguments[0];
  if (intMonth>11) {
    retValue.setUTCFullYear (retValue.getUTCFullYear ()+(intMonth-intMonth%12)/12);
    intMonth=intMonth%12;
  }
  if (intMonth<0) {
    intMonth+=12;
    retValue.setUTCFullYear (retValue.getUTCFullYear ()-1);
  }
  retValue.setUTCMonth (intMonth);
  
  return (retValue);
}

function strdate () {

  if (!strdate.arguments.length) return ('');
  
  var retValue=strdate.arguments[0];

  retValue=retValue.replace (/%m/g, (1+this.getUTCMonth ()).toString ().strpad (2, '0', 1));
  retValue=retValue.replace (/%d/g, this.getUTCDate ().toString ().strpad (2, '0', 1));
  retValue=retValue.replace (/%Y/g, (this.getUTCFullYear ()));
  retValue=retValue.replace (/%y/g, (this.getUTCFullYear ()).toString ().substr (2));

  retValue=retValue.replace (/%F/g, Date.arrMonth[(this.getUTCMonth ())]);
  retValue=retValue.replace (/%M/g, Date.arrMonthShort[(this.getUTCMonth ())]);

  return (retValue);
}


function GetDaysInMonth () {

  var objDate=new Date (this.getUTCFullYear (), (this.getUTCMonth ()+1)%12, 1);
  return (objDate.GetFutureDate (-1).getUTCDate ());
  
}

Date.prototype.SetDate = function (paramYear, paramMonth, paramDay) {

  this.setUTCDate (paramDay);
  this.setUTCMonth ((paramMonth-1));
  this.setUTCFullYear (paramYear);

}