Here's my HOLIDAYS exec. It can also pass back the list of holidays to a calling program. You can tweak the holidays computed to match your local holidays ... Perry /*REXX*/ /* * Find on what days the statutory holidays for a given year * will be taken. */ arg year . year = strip(year) if \validate(year'0101','S') then do say "You must provide a positive year of the form nnnn" return 4 end /* * New Years Day * January 1st (unless a weekend) */ nyd = date('B',year'0101','S') if nyd//7 > 4 then nyd = nyd + (7 - (nyd//7)) /* move to Monday */ holidays.1 = nyd "New Years Day" /* * Good Friday (Friday before Easter Sunday) * Easter Monday (Monday after Easter Sunday) * * In order to figure out these two we figure out Easter Sunday. * These calculations are adapted from those in the paper * Calendrical Calculations from Software Practice and Experience * Volume 20(9). * * Easter Sunday is defined as the first Sunday after the first * full moon occurring on or before the vernal equinox. Read the * paper for more details. */ cent = (year%100) + 1 /* what century we're in */ epact = ((year//19)*11)+14+, /* Nicaean Easter rule */ -((cent*3)%4) +, /* adjusted for Gregorian */ (((cent*8)+5)%25) +, /* adjusted for Metonic cycle */ (cent*30) epact = epact//30 adj_ep = epact if (epact = 0) | ((epact = 1) & (10 < (year//19))) then adj_ep = adj_ep + 1 /* adjusted for 29.5 day months */ es = date('B',year'0419','S') - adj_ep + 7 /* Paschal moon */ if es//7 <> 6 then es = es - (es//7) - 1 /* force back to previous Sunday */ holidays.2 = es-2 "Good Friday" holidays.3 = es+1 "Easter Monday" /* * Queen's Birthday (aka Victoria Day) * first Monday on or before the 24th of May */ qbd = date('B',year'0524','S') qbd = qbd - (qbd//7) /* force to previous Monday */ holidays.4 = qbd "Victoria Day" /* * Dominion Day (aka Canada Day) * July 1st (unless a weekend) */ dd = date('B',year'0701','S') if dd//7 > 4 then dd = dd + (7 - (dd//7)) /* move to Monday */ holidays.5 = dd "Canada Day" /* * BC Day * First Monday in August */ bcd = date('B',year'0801','S') if bcd//7 <> 0 then bcd = bcd + (7 - (bcd//7)) /* move to Monday */ holidays.6 = bcd "BC Day" /* * Labour Day * First Monday in September */ ld = date('B',year'0901','S') if ld//7 <> 0 then ld = ld + (7 - (ld//7)) /* move to Monday */ holidays.7 = ld "Labour Day" /* * Thanksgiving Day * Second Monday in October */ td = date('B',year'1001','S') + 7 if td//7 <> 0 then td = td + (7 - (td//7)) /* move to Monday */ holidays.8 = td "Thanksgiving Day" /* * Remembrance Day * November 11th (unless a weekend) */ rd = date('B',year'1111','S') if rd//7 > 4 then rd = rd + (7 - (rd//7)) /* move to Monday */ holidays.9 = rd "Remembrance Day" /* * Christmas Day * December 25th (unless a weekend) */ cd = date('B',year'1225','S') if cd//7 > 4 then cd = cd + (7 - (cd//7)) /* move to Monday */ holidays.10 = cd "Christmas Day" /* * Boxing Day * December 26th (unless a weekend) * (basically the day after Christmas) */ bd = cd+1 if bd//7 > 4 then bd = bd + (7 - (bd//7)) /* move to Monday (or Tuesday) */ holidays.11 = bd "Boxing Day" holidays.0 = 11 /* count of holidays */ parse source sysname call_type . if call_type = "COMMAND" then do do i = 1 to holidays.0 parse value holidays.i with date name say date('W',date,'B') date('N',date,'B') "is" name end end; else if sysname = "CMS" then 'PIPE STEM HOLIDAYS. ', '| STEM HOLIDAYS. 1' else say "Use a decent operating system" return 0 validate: signal on syntax name invalid_date call date arg(2),arg(1),arg(2) return (1==1) invalid_date: return (0==1)
Perry Ruiter 250-658-6517 ----- Message from "Buettner, Wolfgang" <wolfgang.buett...@softwareag.com> on Wed, 29 Dec 2010 14:42:04 +0100 ----- Subject: Movable Feasts We have some services which should be up during normal working hours only, i.e. not on weekends and not on public holidays either. Could be done by WAKEUP, but ... How to code movable feasts like Easter Monday and others depending on the first full moon in spring? I know the formula is complex, so I believe it would be very much simpler to get those dates from an actual calendar and hard-code them each year than to write a REXX. Any other ideas? Thank you and a Happy New Year, Wolfgang Software AG – Group Executive Board: Karl-Heinz Streibich (Vorsitzender/Chairman), Arnd Zinnhardt, Mark Edwards, David Broadbent, Josef Bommersbach, Dr. Wolfram Jost, Kamyar Niroumand, Ivo Totev Sitz/Registered office: Uhlandstraße 12, 64297 Darmstadt, Germany, – Registergericht/Commercial register: Darmstadt HRB 1562 - Vorstand/ Management Board: Karl-Heinz Streibich (Vorsitzender/Chairman), David Broadbent, Dr. Wolfram Jost, Arnd Zinnhardt; - Aufsichtsratsvorsitzender/ Chairman of the Supervisory Board: Dr. Andreas Bereczky - http://www.softwareag.com