home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / pasdox / time.txt < prev   
Text File  |  1985-11-18  |  4KB  |  129 lines

  1. { -----------------------------------------------------------------------------
  2.  
  3.                                  NOTICE:
  4.  
  5.       THESE MATERIALS are UNSUPPORTED by OSS!  If you do not understand how to
  6.       use them do not contact OSS for help!  We will not teach you how to 
  7.       program in Pascal.  If you find an error in these materials, feel free
  8.       to SEND US A LETTER explaining the error, and how to fix it.
  9.  
  10.       THE BOTTOM LINE:
  11.  
  12.          Use it, enjoy it, but you are on your own when using these materials!
  13.  
  14.  
  15.                                DISCLAIMER:
  16.  
  17.       OSS makes no representations or warranties with respect to the contents
  18.       hereof and specifically disclaim all warranties of merchantability or
  19.       fitness for any particular purpose.   This document is subject to change
  20.       without notice.
  21.       
  22.       OSS provides these materials for use with Personal Pascal.  Use them in
  23.       any way you wish.
  24.  
  25.    -------------------------------------------------------------------------- }
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Time and Date                                                           Page 1
  32.  
  33.                            Time and Date Functions
  34.  
  35. If  you are writing an application which needs to find out the current time or
  36. date, you can call certain system routines to find out those values  (provided
  37. the user has set them using the control panel!).  The first routine allows you
  38. to retrieve the current date:
  39.  
  40. Get date.
  41.  
  42. FUNCTION t_getdate : Integer ;
  43.   GEMDOS( $2a ) ;
  44.  
  45. Use this call to retrieve the system date, in the following format:
  46.  
  47.  bits  contents
  48. -----  --------
  49.  0- 4  the day of the month (1-31)
  50.  5- 8  the month of the year (1-12)
  51.  9-15  the number of years since 1980 (0-119)
  52.  
  53. For example, the date February 5, 1986 would be:
  54.  
  55. $0C45 = 6*512 + 2*32 + 5
  56. (0000 1100 0100 0101 in binary)
  57.  
  58. Set date.
  59.  
  60. FUNCTION t_setdate( date : Integer ) : Integer ;
  61.   GEMDOS( $2b ) ;
  62.  
  63. This  call  is  used  to set the date, in the same format given for t_getdate,
  64. above.  It returns 0, if the date was  valid,  or  a  negative  error  number,
  65. otherwise.
  66.  
  67. Get time.
  68.  
  69. Of  course,  the  date  alone is not enough.  You also need to set and get the
  70. current system time.  This time value is only accurate to an  even  number  of
  71. seconds,  however,  since  there  are  only 5 bits allocated for returning the
  72. current second.
  73.  
  74. FUNCTION t_gettime : Integer ;
  75.  
  76. Use this call to find our the  current  system  time  since  midnight  on  the
  77. current day.  The time is returned as an integer in the following format:
  78.  
  79.  bits   contents
  80. -----   --------
  81.  0- 4   number of two-seconds (0-29)
  82.  5-10   number of minutes (0-59)
  83. 11-15   number of hours (0-23)
  84.  
  85. Notice that the seconds returned is the number of two-second intervals, so you
  86. have  to  multiply  by two to get the number of seconds.  This also means that
  87. the clock is only accurate to an even number of seconds.
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. Time and Date                                                           Page 2
  98.  
  99. Set time.
  100.  
  101. FUNCTION t_settime( time : integer ) : integer ;
  102.   GEMDOS( $2d ) ;
  103.  
  104. This call sets the time using the same  format  as  the  t_gettime  call.   It
  105. returns 0, if the time was valid, and a negative error number, otherwise.
  106.  
  107.  
  108. The calls described above are the "GEMDOS" calls for date and time.  There are
  109. also  underlying  XBIOS  calls  to  perform  the same functions.  As usual, we
  110. advise that you use the GEMDOS  calls  whenever  possible  (unless  they  have
  111. bugs!).
  112.  
  113. Set the system date and time.
  114.  
  115. PROCEDURE settime( date, time : integer ) ;
  116.   XBIOS( 22 ) ;
  117.  
  118. This  call  sets  the date and time in the intelligent keyboard.  The date and
  119. time are the same format as the GEMDOS set date and set time  calls  described
  120. above.  You should normally use the GEMDOS calls, not this call.
  121.  
  122. Get the system date and time.
  123.  
  124. FUNCTION gettime : Long_Integer ;
  125.   XBIOS( 23 ) ;
  126.  
  127. This  call  returns the current date in the high word of the result parameter,
  128. and the current time in the low word, both in standard GEMDOS format.
  129. sssssssssssss