Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-08

printing each Friday the 13 using Pascal

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo
to ik

Converting one of the answers there...

uses
  SysUtils;
const
  StartingYear = 2012;
var
  Year,Month: Byte;
  Date: TDateTime;
begin
  for Year in [0 .. 5] do begin
    for Month in [1 .. 12] do begin
      Date := EncodeDate(Year,Month,13);
      if DayOfWeek(Date) = 5 then begin
        WriteLn(FormatDateTime('YYYY-MM-DD',Date));
      end;
    end;
  end;
end.
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/printing-each-Friday-the-13-using-Pascal-tp5710496p5710497.html Sent from the Free Pascal - General mailing list .
Gerhard Scholz
to ik: A friend of mine started a hobby project: Printing every Friday the 13, in a range of 5…

a quick and dirty solution

Earlier message 21 lines
----- Original Message ----- From: ik To: FPC-Pascal users discussions Sent: Monday, August 06, 2012 1:19 PM Subject: [fpc-pascal] printing each Friday the 13 using Pascal Hi list, A friend of mine started a hobby project: Printing every Friday the 13, in a range of 5 years. I lack of the time for doing it at the moment, and I wish to add to his github also Pascal (and show how much simpler it is then C) implementation. Is there anyone here that might be interested in this ? Ido
Howard Page-Clark
to leledumbo: Converting one of the answers there... uses SysUtils; const StartingYear = 2012; var…

On 06/8/12 1:32, leledumbo wrote:

Minor amendment needed to leledumbo's code to give Friday, and a five year range:

uses SysUtils;
const startYr: word = 2012;
var dt: TDateTime;
     year, month: word;
begin
   for year in [0..4] do
    for month in [1..12] do
     begin
       dt := EncodeDate(startYr + year, month, 13);
       if (DayOfWeek(dt) = 6) then
        begin
    	 writeln(FormatDateTime('DDDD, DD-MM-YYYY',dt));
        end;
     end;
end.

Howard