{ ----------------------------------------------------------------------------- NOTICE: THESE MATERIALS are UNSUPPORTED by OSS! If you do not understand how to use them do not contact OSS for help! We will not teach you how to program in Pascal. If you find an error in these materials, feel free to SEND US A LETTER explaining the error, and how to fix it. THE BOTTOM LINE: Use it, enjoy it, but you are on your own when using these materials! DISCLAIMER: OSS makes no representations or warranties with respect to the contents hereof and specifically disclaim all warranties of merchantability or fitness for any particular purpose. This document is subject to change without notice. OSS provides these materials for use with Personal Pascal. Use them in any way you wish. -------------------------------------------------------------------------- } Time and Date Page 1 Time and Date Functions If you are writing an application which needs to find out the current time or date, you can call certain system routines to find out those values (provided the user has set them using the control panel!). The first routine allows you to retrieve the current date: Get date. FUNCTION t_getdate : Integer ; GEMDOS( $2a ) ; Use this call to retrieve the system date, in the following format: bits contents ----- -------- 0- 4 the day of the month (1-31) 5- 8 the month of the year (1-12) 9-15 the number of years since 1980 (0-119) For example, the date February 5, 1986 would be: $0C45 = 6*512 + 2*32 + 5 (0000 1100 0100 0101 in binary) Set date. FUNCTION t_setdate( date : Integer ) : Integer ; GEMDOS( $2b ) ; This call is used to set the date, in the same format given for t_getdate, above. It returns 0, if the date was valid, or a negative error number, otherwise. Get time. Of course, the date alone is not enough. You also need to set and get the current system time. This time value is only accurate to an even number of seconds, however, since there are only 5 bits allocated for returning the current second. FUNCTION t_gettime : Integer ; Use this call to find our the current system time since midnight on the current day. The time is returned as an integer in the following format: bits contents ----- -------- 0- 4 number of two-seconds (0-29) 5-10 number of minutes (0-59) 11-15 number of hours (0-23) Notice that the seconds returned is the number of two-second intervals, so you have to multiply by two to get the number of seconds. This also means that the clock is only accurate to an even number of seconds. Time and Date Page 2 Set time. FUNCTION t_settime( time : integer ) : integer ; GEMDOS( $2d ) ; This call sets the time using the same format as the t_gettime call. It returns 0, if the time was valid, and a negative error number, otherwise. The calls described above are the "GEMDOS" calls for date and time. There are also underlying XBIOS calls to perform the same functions. As usual, we advise that you use the GEMDOS calls whenever possible (unless they have bugs!). Set the system date and time. PROCEDURE settime( date, time : integer ) ; XBIOS( 22 ) ; This call sets the date and time in the intelligent keyboard. The date and time are the same format as the GEMDOS set date and set time calls described above. You should normally use the GEMDOS calls, not this call. Get the system date and time. FUNCTION gettime : Long_Integer ; XBIOS( 23 ) ; This call returns the current date in the high word of the result parameter, and the current time in the low word, both in standard GEMDOS format. sssssssssssss