Last Friday of each month: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added/changed whitespace and comments, used a template for the output section.)
m (→‎{{header|REXX}}: redid the boxed comments in the REXX preamble.)
Line 3,226: Line 3,226:
<br>It wasn't optimized just to find a particular day-of-week.
<br>It wasn't optimized just to find a particular day-of-week.


The documentation for the '''lastDOW''' function &nbsp; (used in the REXX program below):
The documentation for the &nbsp; '''lastDOW''' &nbsp; function &nbsp; (used in the REXX program below):


╔════════════════════════════════════════════════════════════════════════════════════════════════╗
╔════════════════════════════════════════════════════════════════════╗
║ lastDOW: procedure to return the date of the last day─of─week of ║
║ lastDOW: procedure to return the date of the last day─of─week of any particular month of any
any particular month of any particular year.
║ particular year.
║ The day─of─week must be specified (it can be in any case,
║ The day─of─week must be specified (it can be in any case, (lower─/mixed─/upper─case) as an
English name of the spelled day of the week, with a minimum length that causes no ambiguity. ║
║ (lower─/mixed─/upper─case) as an English name of the spelled day ║
of the week, with a minimum length that causes no ambiguity.
║ I.E.: W for Wednesday, Sa for Saturday, Su for Sunday ... ║
║ I.E.: TU for Tuesday. W for Wednesday, Sa for Saturday, Su for Sunday ...
║ The month can be specified as an integer 1 ──► 12 ║
║ The month can be specified as an integer 1 ──► 12
║ 1=January 2=February 3=March ... 12=December
║ 1=January 2=February 3=March 4=April 5=May 6=June ... 12=December ║
║ or the English name of the month, with a minimum length that ║
║ or the English name of the month, with a minimum length that causes no ambiguity.
causes no ambiguity. I.E.: Jun for June, D for December.
I.E.: JA for January, AP for April, JUN for June, JUL for July, D for December.
║ If omitted [or an asterisk(*)], the current month is used. ║
║ If omitted [or an asterisk(*)], the current month is used.
║ The year is specified as an integer or just the last two digits ║
║ The year is specified as an integer or just the last two digits (two digit years are assumed
(two digit years are assumed to be in the current century, and ║
║ to be in the current century, and there is no windowing for a two─digit year). If omitted
there is no windowing for a two─digit year).
[or an asterisk(*)], the current year is used. Years < 100 must be specified with (at
║ least 2) leading zeroes. ║
║ If omitted [or an asterisk(*)], the current year is used. ║
║ ║
║ Years < 100 must be specified with (at least 2) leading zeroes.║
║ The method used is: find the "day number" of the 1st of the next month and then subtract one ║
Method used: find the "day number" of the 1st of the next month ║
(this gives the "day number" of the last day of the month, bypassing the leapday mess). The
last day─of─week is then obtained straightforwardly, or via subtraction.
║ then subtract one (this gives the "day number" of the last day of ║
╚════════════════════════════════════════════════════════════════════════════════════════════════╝
║ the month, bypassing the leapday mess). The last day─of─week is ║
then obtained straightforwardly, or via subtraction. ║
╚════════════════════════════════════════════════════════════════════╝
<lang rexx>/*REXX program displays the dates of the last Fridays of each month for any given year.*/
<lang rexx>/*REXX program displays the dates of the last Fridays of each month for any given year.*/
parse arg yyyy /*obtain optional argument from the CL.*/
parse arg yyyy /*obtain optional argument from the CL.*/