home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxdate.zip / RexxDate.INF (.txt) < prev    next >
OS/2 Help File  |  1994-03-10  |  4KB  |  113 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Introduction ΓòÉΓòÉΓòÉ
  3.  
  4. RexxDate is a group of functions for Rexx that allow manipulation of dates. The 
  5. following functions are available: 
  6.  
  7.      Function            Purpose 
  8.  
  9.      RexxDate_Init       Registers the RexxDate functions. 
  10.      RexxDate_Diff       Returns the difference in days between two dates. 
  11.      RexxDate_Drop       Deregisters the RexxDate functions.  This drops ALL 
  12.                          the functions. 
  13.      RexxDate_Isleap     Returns 1 if the year is a leap year, otherwise 0. 
  14.  
  15.  
  16. ΓòÉΓòÉΓòÉ 2. Using RexxDate Functions ΓòÉΓòÉΓòÉ
  17.  
  18. The RexxDate functions are used by calling them in REXX statements. 
  19.  
  20.  
  21. ΓòÉΓòÉΓòÉ 2.1. Registering RexxDate Functions ΓòÉΓòÉΓòÉ
  22.  
  23. The RexxDate functions must be registered before they can be used.  This is 
  24. done by calling RexxDate_Init which registers all the functions for use. 
  25.  
  26.  
  27. ΓòÉΓòÉΓòÉ 2.2. Unregistering (dropping) RexxDate Functions ΓòÉΓòÉΓòÉ
  28.  
  29. The RexxDate functions can be unregistered (dropped) if they are no longer 
  30. needed.  This is done by calling RexxDate_Drop. 
  31.  
  32.  
  33. ΓòÉΓòÉΓòÉ 3. The RexxDate Functions ΓòÉΓòÉΓòÉ
  34.  
  35. The RexxDate functions are: 
  36.  
  37.      Function            Purpose 
  38.  
  39.      RexxDate_Init       Registers the RexxDate functions. 
  40.      RexxDate_Diff       Returns the difference in days between two dates. 
  41.      RexxDate_Drop       Deregisters the RexxDate functions.  This drops ALL 
  42.                          the functions. 
  43.      RexxDate_Isleap     Returns 1 if the year is a leap year, otherwise 0. 
  44.  
  45.  
  46. ΓòÉΓòÉΓòÉ 3.1. RexxDate_Init - Register functions. ΓòÉΓòÉΓòÉ
  47.  
  48. RexxDate_init registers the RexxDate functions for use by REXX. 
  49.  
  50. if RxFuncQuery('RexxDate_Init')
  51.   then
  52.     do
  53.       retcode = RxFuncAdd(RexxDate_Init, 'REXXDATE', 'RexxDate_Init')
  54.       retcode = RexxDate_Init()
  55.       Wasregistered = 0
  56.     end /* end do */
  57.   else
  58.     Wasregisterd = 1
  59.  
  60. It is good practice to determine whether or not the function is already 
  61. registered.  If it is you do not want to drop it as that will prevent the other 
  62. users from accessing it. 
  63.  
  64.  
  65. ΓòÉΓòÉΓòÉ 3.2. RexxDate_Diff - Difference in days ΓòÉΓòÉΓòÉ
  66.  
  67. RexxDate_Diff returns the difference in days between two dates.  It can be 
  68. called with one or two arguments: 
  69.  
  70.      RexxDate_Diff(date1, date2)     Returns the difference between date1 and 
  71.                                      date2 (date1 - date2) in days. 
  72.      RexxDate_Diff( , date2)         Returns the difference between the current 
  73.                                      date and date2 (now - date2) in days. 
  74.      RexxDate_Diff(date1)            Returns the difference between date1 and 
  75.                                      the current date (date1 - now) in days. 
  76.  
  77.  The date must be in the format MM/DD/YY i.e. 2/4/49, 1/32/92. 
  78.  
  79.     date1 = '2/28/94'
  80.     date2 = '2/18/94'
  81.     diff = RexxDate_Diff(date1,date2)
  82.     say 'Difference in days between' date1 'and' date2 'is' diff
  83.  
  84.   This returns:
  85.  
  86.     Difference in days between 2/28/94 and 2/18/94 is 10
  87.  
  88.  
  89. ΓòÉΓòÉΓòÉ 3.3. RexxDate_Drop - Drop RexxDate functions ΓòÉΓòÉΓòÉ
  90.  
  91. RexxDate_Drop is used to unregister (drop) the RexxDate functions. 
  92.  
  93.   if (\WasRegistered)
  94.     then
  95.       retcode = RexxDate_Drop()
  96.  
  97.  
  98. ΓòÉΓòÉΓòÉ 3.4. RexxDate_Isleap - Leap year check ΓòÉΓòÉΓòÉ
  99.  
  100. RexxDate_Isleap returns 1 if the year is a leap year, otherwise 0.  Any year 
  101. that is returns no remainder when divided by four AND returns a remainder when 
  102. divide by 100 OR has no remainder when divided by 400 is assumed to be a leap 
  103. year. 
  104.  
  105.  
  106.   parse value DATE('U') with mon'/'day'/'yr
  107.   Do year = 1900 + yr to 2010
  108.      say  year RexxDate_Isleap(year)
  109.   end /* do */
  110.  
  111. The years 96, 2000, 2008 should return a 1, the rest will return 0. 
  112.  
  113. The year must be in YYYY format (all four digits must be specified).