Similar, here's my REXDATES EXEC that either:
- shows today's date in the various REXX formats
- shows an input date in various formats
If called from XEDIT, the result is shown in XEDIT's message area (hoping
you used SET MSGLINE to define enough lines).
/* show all rexx date() variations
+-----------------------------------------------------------+
| format: | REXDATES <inputdate> |
+-----------------------------------------------------------+
(c) Copyright International Business Machines Corporation 1986, 2006.
All Rights Reserved.
21 Dec 2000: Accept an input date
Written by: Kris Buelens IBM Belgium Feb 1986 */
call csl 'DMSINXED RETC REAS T'; Xedit=(reas=0 & t=0)
parse arg Indate '' t ; indate=strip(indate)
fmts='Basedate Century Days European Julian Month Normal Ordered',
'Sorted Usa Weekday'
NbFm=words(fmts)
if inDate='' then do
call say 'The following DATE formats are available:',
'(you can also pass an input date)'
do i=1 to NbFm
call rexdate word(Fmts,i)
end i
exit
end
if length(indate)=10 then if substr(indate,5,1)substr(indate,8,1)='--'
then indate=left(indate,4)substr(indate,6,2)substr(indate,9)
ValidFmts=''
do i=1 to NbFm
ValidFmts=ValidFmts CkDate(word(fmts,i))
end
If ValidFmts='' then do
Call Say 'Date' indate 'is not a valid REXX date (in any format)'
exit 56
end
call say 'The following DATE formats are available for date "'indate'"'
ld=length(inDate)+19
Do while ValidFmts<>''
out.=''
Do 3 while ValidFmts<>''
parse var ValidFmts fmt ValidFmts
Out.0tit=Out.0tit left(fmt,12)
do i=1 to NbFm
fmto=word(Fmts,i)
out.fmto=out.fmto GivDate(fmtO,Indate,Fmt)
end i
end
call Say right('? ===>',ld+5) Out.0tit
do i=1 to NbFm
fmto=word(Fmts,i)
t='Date('left(fmto,8)','inDate',"?")'
call say ' 'left(t,ld) '= ' Out.fmto
end i
end
exit
REXDATE:
call say ' 'left('Date('arg(1)')',15)'= ' date(arg(1))
return
SAY:
if xedit then address xedit 'COMMAND MSG' arg(1)
else say arg(1)
return
CkDate:
Signal on syntax name InvDate
call date 'U',Indate,arg(1)
return arg(1) /* Format was possible */
InvDate: return '' /* Format was impossible */
GivDate:
Signal on syntax name InvDate2
return left(date(arg(1),arg(2),arg(3)),12)
InvDate2: return '*impossible*'
2011/1/3 Edward M Martin <[email protected]>
> Hello Sergio,
>
> Here is our TODAY EXEC to give you all types of information.
>
> /* REXX IS THIS YEAR A LEAP YEAR ? */
> ADDRESS COMMAND
> SAY DATE() ' DATE EXPRESSED NORMALLY'
> SAY DATE('B') ' DATE EXPRESSED AS DAYS SINCE 01/01/0001 '
> SAY DATE('C') ' DATE EXPRESSED AS DAYS SINCE 01/01/2000 '
> SAY DATE('D') ' NUMBERS OF DAYS THIS YEAR'
> SAY DATE('J') ' JULIAN DATE'
> SAY DATE('E') ' EUROPEAN DATE FORMAT'
> SAY DATE('W') ' DAY OF THE WEEK '
> SAY DATE('M') ' MONTH '
> SAY DATE('N',,,'/',) ' NORMAL DATE WITH SLASHES'
> SAY DATE('O') ' ORDERED DATE '
> SAY DATE('U') ' U DATE '
>
> Ed Martin
> Aultman Health Foundation
> 330-363-5050
> ext 35050
> -----Original Message-----
> From: The IBM z/VM Operating System [mailto:[email protected]] On
> Behalf Of Chip Davis
> Sent: Monday, January 03, 2011 9:56 AM
> To: [email protected]
> Subject: Re: How can get the Week day ?
>
> Be careful with Date('C'). It doesn't really give you the number of
> days in the current century (as it was originally documented). It
> returns the number of days since the beginning of the most recent year
> ending in '00', e.g. '2000'.
>
> If you are doing any sort of arithmetic with dates, your best bet is
> Date('Basedate'), especially if your dates might span a century
> boundary.
>
> -Chip-
>
> On 1/3/11 14:25 George Henke/NYLIC said:
> RTIN_
>
--
Kris Buelens,
IBM Belgium, VM customer support