home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxdates.zip
/
rxdates.DOC
< prev
next >
Wrap
Text File
|
1994-09-18
|
4KB
|
91 lines
Doc file for the rexx routines included in RXDATES.CMD
Denis Tonn 1:153/908@fidonet DTONN@IBM.VNET.COM
July 07 1994
REXX has a rich set of routines to process different date formats. Unfortuately
the routines only work on the current date. I found I had a need to manipulate
dates in various manners and from various sources. Calculating a new date from
a current one was always a challenge. I finally wrote a set of generalized
routines to do this. This routine allows me to pretty well manipulate any date
in any way I wish with minmal reformating from outside the routine. Typically
all that may be required is the REXX parse command outside this routine.
The BaseDate format is particularly useful as an intermediary step in date
calculations. It is totally free of the concept of month, days, years, or leaps.
Because of this, you can numericly manipulate a date and run the result back
through the routine to extract a more "normal" date.
This routine is normally meant to be Called from another Rexx routine.
It can be used from the command line since I left it that way for my
own testing.
It has not been optimized, but seems to work fine. There is no error
checking, so you should do your own outside this routine. In particular,
make sure that what you pass can be evaluated as a string. The call:
return=RXDATES(05/21/1991 F)
will not work right, as REXX will evaluate the 05/21/1991 as an arithmetic
value before passing to RXDATES.CMD. The correct format is:
return=RXDATES('05/21/1991 F')
Most format changes are done through calculations with little table lookups.
If anyone has better formulas to calculate dates in various formats, I would
like to hear from them. Most of this is from pure reasoning on my part.
Usually at 2:am. :-)
If you find errors or additions, you have the source to fix it <grin>.
Format:
return_value=RXDATES(date_to_process return_type)
Input Date types to be processed can be:
Julian (day # of year)
USA (MM/DD/YY or MM/DD/YYYY)
Month Day Year (eg: January 17 1994)
BaseDate (total days since 01/01/0001)
NOTE: Input Julian dates assume current year. Because of this, BaseDates less
than 366 are processed as Julian. Also, to properly handle MM/DD/YYYY
requires that MM/DD/YY be restricted to the current century. These
restrictions do not affect output, but if the output is then reused,
the above restrictions will again apply.
Returned types available are:
'J' - Julian format of date (173)
'U' - USA format (MM/DD/YY)
'F' - Full format (October 23 1992)
'D' - Day number of the week (0 to 6, where 0 is Monday)
'W' - Weekday name (Thursday)
'M' - Month name (June)
'B' - Basedate (days since 01/01/01)
'L' - Leapyear - Rexx boolean (0/1) value. True if leapyear
Format for a call from another rexx routine would be:
USA=RXDATES('Febuary 27 1993 U') - returns the USA format
Julian=RXDATES(08/07/93 'J') - returns the julian date for 08/07/1993
Weekday=RXDATES(37 W) - returns the name/day of the week from day 37 this year
basedate=RXDATES('09/03/1954 B') - returns days from 01/01/0001 to 09/03/1954
I find it particularly useful in calculating future/past dates. Lets say I
want to calculate the MM/DD/YY format of a date 30 days ahead, when my starting
date is today. End of month crossovers and leapyear calculation can make this
tricky.. So:
newUSA=RXDATES((date('B')+30) 'U')
will return the USA format of a date 30 days from now. Also:
weekday=RXDATES((date('B')+30) 'W')
would return the day of the week (name) for the date 30 days from now. And:
daynum=RXDATES((date('B')+30) 'D')
would return the daynumber of the week (0=Monday, 6=Sunday). While:
Julianday=RXDATES((date('B')+30) 'J')
would return the Julian date for then. And lastly:
Fulldate=RXDATES((date('B')+30) 'F')
would return the full Month Day Year value.
See the sample command file RXTDATE.CMD for samples and other formats.