Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#124: extended DayOfWeek function

As you know, the default DayOfWeek function from SysUtils unit returns the day of week for some date. But in this function uses the Sunday as first day of the week and the Saturday as the seventh.

In some countries this function is not useful because the first day of the week is a Monday instead Sunday. The function below can be used in this case:

For example, in code below you'll see how to add in TListView component the rows for each attachment file:

function DayOfWeekMon2Sun(dtDate: TDateTime): Integer;
const
  StartOfWeek: Integer = 2;
begin
  Result := (DayOfWeek(dtDate) - StartOfWeek + 7) mod 7 + 1;
end;

I wrote this function a lot of time ago when I started the development of scheduler program and wanted to add a possibility to define a custom timesheet (like in MS Outlook).

I hope that this function will be useful for you too.

PS: as you see, I used the const value (StartOfWeek) as shift. So if your country use the some other order in days of the week, you can change this const value.


Published: August 30, 2001

See also
 
Excel Reader (dll)
Fast Document Viewer
DBISAM Password Recovery
ABA Picture Convert
SMExport suite
ABA Spreadsheet Convert
Paradox Password Recovery
Excel Web-stream
Word Web-stream
ABA Document Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising