Axaptapedia is now maintained by AgileCadence For more information please click here.
CalendarWeek
From Axaptapedia
<xpp> /// <summary> /// Calculates the Calendar Week of a Date according to the German Standard /// </summary> /// <param name="inputDate">The Date</param> /// <returns>Returns an Integer representing the Calendar Week</returns> /// <remarks> /// <para> /// This Method is only relevant for the German Culture. /// It is considerably faster than the Method /// <see cref="GetInternationalCalendarWeek"/>. /// </para> /// <para> /// The Calculation is based on the /// C++-Algorithm from Ekkehard Hess out of an Article on /// 29 July 1999 in the Newsgroup /// borland.public.cppbuilder.language ///(released for general use) /// </para> /// </remarks>
static int calendarWeek_DE(Date inputDate) {
real a = trunc((14 - (mthOfYr(inputDate))) / 12); real y = year(inputDate) + 4800 - a; real m = (mthOfYr(inputDate)) + (12 * a) - 3; real jd; real d4; real L; real dl; int calendarWeek; ;
jd = str2int(substr(date2str(inputDate, 123, 2, 2, 2, 2, 2), 1, 2)) + trunc(((153 * m) + 2) / 5) + (365 * y) + trunc(y / 4) - trunc(y / 100) + trunc (y / 400) - 32045; d4 = (jd + 31741 - (jd mod 7)) mod 146097 mod 36524 mod 1461; L = trunc(d4 / 1460); dl = ((d4 - L) mod 365) + L;
calendarWeek = trunc(dl / 7) + 1;
return calendarWeek;
} </xpp>