View Single Post
  #4  
Old 02-21-2002, 12:13 AM
Ted On The NeT Ted On The NeT is offline
Senior Member
 
Join Date: Apr 2001
Posts: 2,182
Default Borland's faulty code:

Another piece of code, created by Borland. It doens't work either. try the date: 01-01-2004. In the TMonthCalendar it's week 53. This function returns 1. I've traced the TCommonCalendar's "WeekNumbers" property in the source directory, but it's not usable...

function WeekOfYear(ADate : TDateTime) : word;
var
day : word;
month : word;
year : word;
FirstOfYear : TDateTime;
begin
DecodeDate(ADate, year, month, day);
FirstOfYear := EncodeDate(year, 1, 1);
Result := Trunc(ADate - FirstOfYear) div 7 + 1;
end;



Greetz,
::TeD On The NeT::

=[ QUESTIONS ]=========================================
don't forget to accept this reply if it helped you!
================================================== =====

=[ EXTRA INFO ]========================================
Location : Netherlands (GMT +01.00)
Languages : English, Dutch, German
Age : 25
ICQ : Be smart and figure out what my UIN is...
================================================== =====
Reply With Quote