I used my rdate exec / rdatef function prior to OS/390 2.4 (when the
REXX built in DATE function was enhanced to convert between date
formats). I still do use it at times because the built in function doesn't
support some to / from formats.
http://home.flash.net/~mzelden/mvsfiles/rdate.txt
http://home.flash.net/~mzelden/mvsfiles/rdatef.txt
But this exercise didn't take any conversion.
Speaking of simple, how about this one:
/* rexx */
/* The following was provided by Mark Barnett, Stanford */
/* Linear Accelerator Center: */
/* DAY EXEC -- Given a Gregorian date, returns its weekday */
/* (U.S: Gregorian 9/14/1752 followed 9/2/1752 O.S.--Old Style) */
/* (CACM, 10/72, p. 918; Computerworld, 2/11/80, p. 30) */
/* Accepts m d y with blank, /, or - as separators. Two-digit */
/* years are prefixed with 19 (leading 0's are permitted). */
/* May be appended to another REXX exec, for use as an internal */
/* routine, by "uncommenting" the "Procedure" statement. */
DAY: /* Procedure; */ Signal on SYNTAX; ret=0; n="ARG"()
Arg a1, a2, a3, a4, a5, bad; s=a1 a2 a3 a4 a5; args=s bad
If n>5 | a1='?' Then Signal "SYNTAX"; If a1='' Then s="DATE"('USA')
s="TRANSLATE"(s,' ','/-'); Parse var s m d y bad
If bad^='' Then Signal 'SYNTAX'; If "LENGTH"(y)=2 Then y='19'y
/* m=month d=day y=year (m and y are adjusted during computation) */
y=y+(m-14)%12 /* Adjust month, year; March = month 1 of its */
m=(m+9)//12+1 /* year, February = month 12 of previous.) */
m="TRUNC"(2.6*m-.1) /* Month residue, using Zeller's Congruence */
c=y%100; y=y//100 /* century, year-within-century temporaries */
i=(d+m+y+y%4+5*c+c%4-c%40)//7+1
/* | | | | | | | | > magic from the sky (initial day) */
/* | | | | | | | > modulo 7 days/week */
/* | | | | | | > century years div. by 4000 are not leap */
/* | | | | | > most century years div. by 400 are leap years */
/* | | | | > days/century adjustment: (100+24)*c = 5*c (mod 7) */
/* | | | > one day for each (non-00) leap-year-within-century */
/* | | > one day for each year-within-century: 365 (mod 7) = 1 */
/* | > residual days (mod 28) in previous months (+2) -- Zeller */
/* > day of the month */
w.1='Sunday'; w.2='Monday'; w.3='Tuesday'; w.4='Wednesday'
w.5='Thursday'; w.6='Friday'; w.7='Saturday'; result=w.i
RETURN: Parse SOURCE . s2 s3 .
If s2='COMMAND' & s3='DAY' Then Do
If result^='' Then Say result; Return ret; End
/* Return result */
say result
Return
SYNTAX: Say 'From DAY, called with following argument(s):' args
Say ' '
Say 'DAY returns the day of the week for an input date.'
Say ' '; Say ' DAY <month> <day> <year>'; Say ' '
Say 'where:'; Say ' '
Say ' <month> is the number of the month (January is 1, etc.), and'
Say ' <day> is the day of the month,'
Say ' <year> is the year.'; Say ' '
Say 'Characters / and - are valid separators for the arguments. A'
Say "two-digit <year> is assumed to imply a '19' prefix. If there"
Say "are NO arguments, today's date is assumed. A leading '?' or"
Say 'an argument error yields this message. DAY also may be'
Say 'called as a REXX function, in which case it may be called'
Say 'with either a single or multiple argument strings.'
result=''; If args^='?' Then ret='20040'; Signal 'RETURN'
--
Mark Zelden
Sr. Software and Systems Architect - z/OS Team Lead
Zurich North America / Farmers Insurance Group - ZFUS G-ITO
mailto:***@zurichna.com
z/OS Systems Programming expert at http://expertanswercenter.techtarget.com/
Mark's MVS Utilities: http://home.flash.net/~mzelden/mvsutil.html
On Wed, 24 Sep 2008 13:13:19 +0200, Lindy Mayfield
<***@SSF.SAS.COM> wrote:
>Yes, but there is always a simpler solution:
>
>/* Rexx */
>year=2010
>y=year//100
>c=(year-year//100)/100
>mons = 'Sat Sun Mon Tue Wed Thu Fri'
>say word(mons,((y+trunc(y/4)+31+substr(6420,(c//4)+1,1))//7)+1)
>exit 0
>
>
>-----Original Message-----
>From: IBM Mainframe Discussion List [mailto:IBM-***@BAMA.UA.EDU] On
>Behalf Of Bri P
>Sent: 24. syyskuuta 2008 11:37
>To: IBM-***@BAMA.UA.EDU
>Subject: Re: REXX EXEC
>
> Christmas = 20081225
> Weekday = DATE('W',Christmas,'S')
>
>Brian
>
>-----Original Message-----
>From: IBM Mainframe Discussion List [mailto:IBM-***@BAMA.UA.EDU] On
>Behalf Of Claudio Marcio
>Sent: 24 September 2008 05:21
>To: IBM-***@BAMA.UA.EDU
>Subject: REXX EXEC
>
>Hi,
>
>I need make one REXX exec to enter with one year the return the day
>christmas of week.
>ex: year 1978
> day of th week - monday
>
> year 2000
> day of the week - saturday
>
> how meke in REXX language?
>
>regards
>
>----------------------------------------------------------------------
>For IBM-MAIN subscribe / signoff / archive access instructions,
>send email to ***@bama.ua.edu with the message: GET IBM-MAIN INFO
>Search the archives at http://bama.ua.edu/archives/ibm-main.html
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html