Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
function TForm1.IsFirstDay(aDay: string): boolean;
var
IncDate: TDate;
Day: string;
Today: TDate;
begin
Today := Date;
IncDate := StrToDate('01/'+FormatDateTime('mm', Today)+'/'+FormatDateTime('yyyy', Today));
try
//get first day of month that matches aDay
repeat
Day := FormatDateTime('dddd', IncDate);
IncDate := IncDate+1;
if FormatDateTime('mm', IncDate) <> FormatDateTime('mm', Today) then
raise Exception.Create('');
until Day = aDay;
IncDate := IncDate-1;
//is that day today?
Result := (IncDate = Date);
except
Result := False;
MessageDlg('End of month found without finding a match for the day!', mtError, [mbOK], 0);
end;
end;
if IsFirstDay('Monday') then
ShowMessage('Today''s the day!')
else
ShowMessage('Not today');
function IsSecondTuesday ( dat: TDate ): boolean;
var
d, m, y: word;
begin
DecodeDate ( dat, y, m, d );
result := ( DayofWeek(dat) = 3 ) and ( d in [ 8 .. 14 ] );
end;
if IsSecondTuesday ( Now ) then
ShowMessage ( 'Today is second Tuesday' )
else
ShowMessage ( 'Today is not second Tuesday' );
function IsThisRequiredDay ( dat: TDate; week: integer; day: string ): boolean;
var
dow: integer;
y, m, d: word;
begin
result := false;
if LongDayNames [ DayOfWeek(dat) ] <> day then
exit;
DecodeDate ( dat, y, m, d );
if ( d > week * 7 ) or ( d < ( week * 7 - 6 ) ) then
exit;
result := true;
end;
if IsThisRequiredDay ( Now, 2, 'Tuesday' ) then
ShowMessage ( 'Today is second Tuesday' )
else
ShowMessage ( 'Today is not second Tuesday' );