home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / qbdates / qbdates.doc < prev    next >
Text File  |  1987-02-21  |  8KB  |  162 lines

  1. ==============================================================================
  2. QBDATES.DOC        Assembler Date Functions for QuickBASIC            02/21/87 
  3. ==============================================================================
  4.  
  5.                            Benchmark Software Corp. 
  6.                               Shelburne, VT 
  7.                               (802)862-7948 
  8.                                Jack Stefiuk 
  9.  
  10.  
  11.      DATE2INT - Validate & convert a string date to a sequential integer
  12.      INT2DATE - Convert a sequential integer back to a string date 
  13.  
  14. The primary purpose of the above functions is to convert string dates to
  15. sequential integers and back again.  They may also be used to validate or
  16. determine the day-of-week for a given date.  When used together, these two
  17. functions will allow you to perform any of the following:
  18.  
  19.              * Save disk/RAM space - only 2 bytes/date 
  20.              * Easily sort dates using an integer sort 
  21.              * Calculate the number of days between dates 
  22.              * Determine a 2nd date, a number of days from a 1st date 
  23.              * Determine the day-of-week for a given date 
  24.              * Check the validity of a date (including leap-years) 
  25.              * Determine if the system date has been set 
  26.  
  27.      >>>>>>> Refer to DATEDEMO.BAS for specific examples. <<<<<<<
  28.  
  29. These functions differ from standard date conversions in that 01/01/1980 is used
  30. as a base (returns 0).  Earlier dates return negative numbers and later dates,
  31. positive numbers.  This method provides a very useful range within the confines
  32. of an integer value: 
  33.                       -32768 = 04/14/1890   (Earliest) 
  34.                           -1 = 12/31/1979 
  35.                            0 = 01/01/1980 
  36.                            1 = 01/02/1980 
  37.                        32768 = 09/17/2069   (Latest) 
  38.  
  39. The functions can handle 10 byte "MM/DD/YYYY" or 8 byte "MM/DD/YY" date formats. 
  40. If the latter is used, the functions assume the century to be 1900 and
  41. consequently, the range is reduced:
  42.  
  43.                       -22129 = 01/01/00     (Earliest) 
  44.                           -1 = 12/31/79 
  45.                            0 = 01/01/80 
  46.                            1 = 01/02/80 
  47.                         7304 = 12/31/99     (Latest) 
  48.  
  49. Both functions return the day-of-week (0-6), where 0=Sunday, etc.  
  50.  
  51. The functions, written in assembly language, have been tested with QuickBASIC
  52. v2.0 but should work with other compiled BASICs as well.  These programs are
  53. intended for personal use only.  No charge may be made for their distribution,
  54. including "disk fees", etc.  This is my way of thanking all the Syops for
  55. their efforts.  I hope you find them useful.
  56. USING THE FUNCTIONS WITH YOUR PROGRAMS
  57.  
  58.  
  59. The two functions, INT2DATE & DATE2INT, may be incorporated in your programs
  60. in any one of three ways.  In the following examples, substitute your own
  61. QuickBASIC application program for DATEDEMO.
  62.  
  63.  
  64.        A. LINKING THE INDIVIDUAL OBJECT FILES
  65.           1. Create your QuickBASIC program, making the calls as needed.
  66.           2. Compile your program with either the  ".Obj (BCOM.LIB)" or
  67.              ".Obj (BRUN.LIB)" output options.
  68.           3. Exit QuickBASIC
  69.           4  Link the object files together with the command :
  70.  
  71.                   LINK DATEDEMO+INT2DATE+DATE2INT;
  72.  
  73.  
  74.  
  75.       B. LINKING WITH A LIBRARY FILE
  76.           1. Create your QuickBASIC program, making the calls as needed.
  77.           2. Compile your program with either the  ".Obj (BCOM.LIB)" or
  78.              ".Obj (BRUN.LIB)" output options.
  79.           3. Exit QuickBASIC
  80.           4  Link the object files together with the command :
  81.  
  82.                   LINK DATEDEMO,,,QBDATES.LIB;
  83.  
  84.  
  85.  
  86.        C. USING THE QBDATES.EXE FILE (USER LIBRARY)
  87.           1. Start QuickBASIC with the following command :
  88.  
  89.                   QB DATEDEMO /L QBDATES.EXE    ( .EXE is REQUIRED !)
  90.  
  91.           2. Create your QuickBASIC program, making the calls as needed.
  92.           3. Compile your program with either the  "Memory" or "Exe" output
  93.              options.
  94.  
  95.  
  96.  
  97. All of the files mentioned above are included as part of this package:
  98.  
  99.                   DATE2INT.OBJ  (Method A)
  100.                   INT2DATE.OBJ  (Method A)
  101.                   QBDATES.LIB   (Method B)
  102.                   QBDATES.EXE   (Method C)
  103.  
  104.                   DATEDEMO.BAS  (Demo program)
  105.                   QBDATES.DOC   (This document)
  106.  
  107.  
  108. SUMMARY
  109.  
  110. ------------------------------------------------------------------------------
  111. Function : DATE2INT(DAT$,NUM%,DAY%) 
  112. Arguments: DAT$ - (Passed)   String date in either of two forms: 
  113.                      01/01/00 thru 12/31/99            ( 8 byte format)
  114.                    04/14/1890 thru 09/17/2069          (10 byte format)
  115.            NUM% - (Returned) Sequential signed integer 
  116.                        -29219 thru  7304               ( 8 byte format)
  117.                        -32768 thru 32767               (10 byte format)
  118.            DAY% - (Returned) Day-of-Week or ERROR code 
  119.                          -2 = ERROR (DAT$ is invalid length)
  120.                          -1 = ERROR (Invalid Date)
  121.                           0 = Sunday
  122.                           . . . . . .
  123.                           6 = Saturday
  124. Purpose  : Converts date-string to a sequential signed integer 
  125. Comments : The function automatically determines the length of DAT$.
  126.            If DAT$ is 8 bytes, the century is assumed to be 1900. 
  127.            If DAT$ is not exactly 8 or 10 bytes long, DAY% returns -2. 
  128.            If DAT$ contains an invalid date, DAY% returns -1.
  129. ------------------------------------------------------------------------------
  130. Function : INT2DATE(DAT$,NUM%,DAY%) 
  131. Arguments: DAT$ - (Returned) String date in one of three formats: 
  132.                      01/01/00 thru 12/31/99            ( 8 byte format)
  133.                    04/14/1890 thru 09/17/2069          (10 byte format)
  134.                April 14, 1890 thru September 17, 2069  (18 byte format)
  135.            NUM% - (Passed) Sequential signed integer 
  136.                        -29219 thru  7304               ( 8 byte format)
  137.                        -32768 thru 32767               (10 byte format)
  138.                        -32768 thru 32767               (18 byte format)
  139.            DAY% - (Returned) Day-of-Week or ERROR code 
  140.                          -2 = ERROR (DAT$ is invalid length)
  141.                          -1 = ERROR (Invalid Date)
  142.                           0 = Sunday
  143.                           . . . . . .
  144.                           6 = Saturday
  145. Purpose  : Converts sequential signed integer to a date-string
  146. Comments : The format of the returned date-string is automatically determined
  147.            by the length of DAT$.
  148.            If DAT$ is 8 bytes, the century is assumed to be 1900. 
  149.            If DAT$ is not exactly 8, 10, or 18 bytes long, DAY% returns  -2. 
  150.            If DAT$ is 8 bytes long and NUM% is out of range, DAY% returns  -1.
  151. ------------------------------------------------------------------------------
  152.  
  153. NOTES:     ZERO's ARE REQUIRED for 8 & 10 byte date-strings ! 
  154.            The slashes (/), may be replaced with any other character ie (-). 
  155.  
  156.                 VALID DATES            INVALID DATES 
  157.                 -----------            ------------- 
  158.                 01/01/1980             01/ 1/1980 
  159.                 01/01/80                1/01/80 
  160.                 01-01-1980             01011980 
  161.                 01 01 80               1/1/80 
  162.