Scalabium Software

SMReport Autogenerated
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
 
Mail parser (ActiveX)
Excel Reader (dll)
Viewer for TNEF-files (winmail.dat)
DBExport tools
Database Information Manager
DBISAM Viewer
ABA Document Convert
Viewer for MS Outlook Messages
DBISAM Password Recovery
Fast Document Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising