Scalabium Software

SMExport advertising
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
 
Clarion to Text converter
Viewer for TNEF-files (winmail.dat)
SMImport suite
ABA Spreadsheet Convert
Word Web-stream
Excel Web-stream
Protected Storage Viewer
Excel Reader (dll)
ExcelFile Viewer
MAPIMail
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising