home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / cs2pmm_m.zip / JCDOW.CMD < prev    next >
OS/2 REXX Batch file  |  1996-04-01  |  3KB  |  55 lines

  1. /******************************* REXX *********************************/
  2. /*  REXX External function to calculate a relative day of the week.   */
  3. /*  Input is the Julian date of the day in question (either           */
  4. /*  yyddd or yyyyddd), output is a number from 1 - 7, with 1=Sunday,  */
  5. /*  7=Saturday.                                                       */
  6. /*                                                                    */
  7. /*  Original program written by Jaime A. Cruz, Jr. and released to    */
  8. /*  the public domain.  If you wish to contact the author, you may    */
  9. /*  do so at 72267.1372@compuserve.com or jcruz@ibm.net.              */
  10. /**********************************************************************/
  11. /*        Argument passed must be in yyddd or yyyyddd format          */
  12. /**********************************************************************/
  13. Parse Upper Arg jul_date, .
  14. Select
  15. /**********************************************************************/
  16. /*  If a five-digit Julian Date was passed, extract the century from  */
  17. /*  the system.                                                       */
  18. /**********************************************************************/
  19.    When Length(jul_date) = 5 Then
  20.       Do
  21.          Parse Value jul_date With 1 jul_year 3 ,
  22.                                    3 y 6
  23.          jul_year = Left(Date('S'), 2) || jul_year
  24.       End
  25. /**********************************************************************/
  26. /*  If a seven-digit Julian Date was passed, we will use the century  */
  27. /*  the user specified.                                               */
  28. /**********************************************************************/
  29.    When Length(jul_date) = 7 Then
  30.       Do
  31.          Parse Value jul_date With 1 jul_year 5 ,
  32.                                    5 y 8
  33.       End
  34. /**********************************************************************/
  35. /*  If an unrecognized date format was used, then we'll default to    */
  36. /*  today's date.                                                     */
  37. /**********************************************************************/
  38.    Otherwise
  39.       Do
  40.          y = Date('D')
  41.          jul_year = Left(Date('S'), 4)
  42.       End
  43. End
  44. /**********************************************************************/
  45. /*    Calculate upon which day of the week the passed date falls.     */
  46. /**********************************************************************/
  47. x = jul_year - 1
  48. z = Trunc(((x / 1) + (x / 4) - (x / 100) + (x / 400)), 0) + y
  49. day = (z // 7) + 1
  50.  
  51. /**********************************************************************/
  52. /*           Return this information back to the invoker.             */
  53. /**********************************************************************/
  54. Return day
  55.