home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxdates.zip / rxdates.DOC < prev    next >
Text File  |  1994-09-18  |  4KB  |  91 lines

  1.  Doc file for the rexx routines included in RXDATES.CMD
  2.  
  3.    Denis Tonn        1:153/908@fidonet       DTONN@IBM.VNET.COM
  4.  
  5.  
  6. July 07 1994
  7.  
  8.  
  9. REXX has a rich set of routines to process different date formats. Unfortuately
  10. the routines only work on the current date. I found I had a need to manipulate
  11. dates in various manners and from various sources. Calculating a new date from
  12. a current one was always a challenge. I finally wrote a set of generalized
  13. routines to do this. This routine allows me to pretty well manipulate any date
  14. in any way I wish with minmal reformating from outside the routine. Typically
  15. all that may be required is the REXX parse command outside this routine.
  16.  
  17. The BaseDate format is particularly useful as an intermediary step in date
  18. calculations. It is totally free of the concept of month, days, years, or leaps.
  19. Because of this, you can numericly manipulate a date and run the result back
  20. through the routine to extract a more "normal" date.
  21.  
  22.    This routine is normally meant to be Called from another Rexx routine.
  23.    It can be used from the command line since I left it that way for my
  24.    own testing.
  25.    It has not been optimized, but seems to work fine. There is no error
  26.    checking, so you should do your own outside this routine. In particular,
  27.    make sure that what you pass can be evaluated as a string. The call:
  28.      return=RXDATES(05/21/1991 F)
  29.    will not work right, as REXX will evaluate the 05/21/1991 as an arithmetic
  30.    value before passing to RXDATES.CMD. The correct format is:
  31.      return=RXDATES('05/21/1991 F')
  32.  
  33.    Most format changes are done through calculations with little table lookups.
  34.    If anyone has better formulas to calculate dates in various formats, I would
  35.    like to hear from them. Most of this is from pure reasoning on my part.
  36.    Usually at 2:am. :-)
  37.  
  38.    If you find errors or additions, you have the source to fix it <grin>.
  39.  
  40.  
  41.   Format:
  42.    return_value=RXDATES(date_to_process return_type)
  43.  
  44.  
  45.    Input Date types to be processed can be:
  46.      Julian (day # of year)
  47.      USA (MM/DD/YY or MM/DD/YYYY)
  48.      Month Day Year (eg: January 17 1994)
  49.      BaseDate (total days since 01/01/0001)
  50.  
  51.    NOTE: Input Julian dates assume current year. Because of this, BaseDates less
  52.          than 366 are processed as Julian. Also, to properly handle MM/DD/YYYY
  53.          requires that MM/DD/YY be restricted to the current century. These
  54.          restrictions do not affect output, but if the output is then reused,
  55.          the above restrictions will again apply.
  56.  
  57.    Returned types available are:
  58.     'J' - Julian format of date (173)
  59.     'U' - USA format (MM/DD/YY)
  60.     'F' - Full format (October 23 1992)
  61.     'D' - Day number of the week (0 to 6, where 0 is Monday)
  62.     'W' - Weekday name (Thursday)
  63.     'M' - Month name (June)
  64.     'B' - Basedate (days since 01/01/01)
  65.     'L' - Leapyear - Rexx boolean (0/1) value. True if leapyear
  66.  
  67.   Format for a call from another rexx routine would be:
  68.    USA=RXDATES('Febuary 27 1993 U') - returns the USA format
  69.    Julian=RXDATES(08/07/93 'J') - returns the julian date for 08/07/1993
  70.    Weekday=RXDATES(37 W) - returns the name/day of the week from day 37 this year
  71.    basedate=RXDATES('09/03/1954 B') - returns days from 01/01/0001 to 09/03/1954
  72.  
  73. I find it particularly useful in calculating future/past dates. Lets say I
  74. want to calculate the MM/DD/YY format of a date 30 days ahead, when my starting
  75. date is today. End of month crossovers and leapyear calculation can make this
  76. tricky.. So:
  77.      newUSA=RXDATES((date('B')+30) 'U')
  78. will return the USA format of a date 30 days from now. Also:
  79.      weekday=RXDATES((date('B')+30) 'W')
  80. would return the day of the week (name) for the date 30 days from now. And:
  81.      daynum=RXDATES((date('B')+30) 'D')
  82. would return the daynumber of the week (0=Monday, 6=Sunday). While:
  83.      Julianday=RXDATES((date('B')+30) 'J')
  84. would return the Julian date for then. And lastly:
  85.      Fulldate=RXDATES((date('B')+30) 'F')
  86. would return the full Month Day Year value.
  87.  
  88.  
  89.  See the sample command file RXTDATE.CMD for samples and other formats.
  90.  
  91.