Last Friday of each month: Difference between revisions
Content added Content deleted
Line 2,905: | Line 2,905: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{works with|Free Pascal}} |
{{works with|Free Pascal}} |
||
Using |
Using Free Pascal's DateUtils library would dramatically simplify the coding (see the Delphi example) but for older Pascal implementations the needed routines are the programmer's responsibility. |
||
<lang Pascal> |
<lang Pascal> |
||
program LastFriday; |
program LastFriday; |
||
Line 2,973: | Line 2,973: | ||
d := DaysInMonth(m, y); |
d := DaysInMonth(m, y); |
||
w := DayOfWeek(m, d, y); |
w := DayOfWeek(m, d, y); |
||
{ |
{ back up as needed to desired weekday } |
||
if w >= k then |
if w >= k then |
||
LastWeekday := d - (ord(w) - ord(k)) |
|||
else |
else |
||
LastWeekday := d - (7 - ord(k)) - ord(w); |
|||
LastWeekday := d; |
|||
end; |
end; |
||