home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / sysutl / nsztime.lbr / MDATE.BZS / MDATE.BAS
Encoding:
BASIC Source File  |  1987-12-07  |  5.0 KB  |  105 lines

  1. 100 REM **** ZTIME-I Microsoft Basic Driver routines ****
  2. 110 REM 
  3. 120 REM Written by: Alan D. Percy
  4. 130 REM Date written: 7/28/84
  5. 140 REM
  6. 150 REM Two routines are provided as follows:
  7. 160 REM Line 7000: Get ASCII date string in string variable DATE$
  8. 170 REM Line 8000: Get binary date in array BDATE%(1-6)
  9. 180 REM
  10. 190 REM The mainline of this program (line 1000) will
  11. 200 REM call the above routines to print the current
  12. 210 REM date and time.
  13. 220 REM
  14. 230 REM The required variables and arrays are defined at line
  15. 240 REM numbers 500 on.  These must also be included with
  16. 250 REM any programs that use the ZTIME-I clock board.
  17. 260 REM
  18. 500 DIM BDATE%(6)     'PLACE TO PUT BINARY DATE AND TIME
  19. 510 CBASE%=&H40      ' address of clock chip
  20. 1000 REM **************************************************
  21. 1010 REM * Begining of Program Mainline to Display Date   *
  22. 1020 REM **************************************************
  23. 1030 GOSUB 7000            'get current date and time in ASCII
  24. 1040 PRINT "Mdate:   Version 1.0    7/28/84"
  25. 1050 PRINT "The current date and time is: ";DATE$
  26. 1060 END
  27. 7000 REM *************************************************
  28. 7010 REM * Get current date and time in ASCII into DATE$ *
  29. 7020 REM *************************************************
  30. 7030 REM The date and time is returned in the following form:
  31. 7040 REM
  32. 7050 REM    Mon Jan 23 10:51:32 AM
  33. 7060 REM
  34. 7070 REM Variables used:
  35. 7080 REM    ZZFLAG%
  36. 7090 REM *************************************************
  37. 7100 DATE$=""           'null out string variable
  38. 7110 GOSUB 8000         'get binary date and time
  39. 7120 IF BDATE%(3) = 1 THEN DATE$="Sun " : GOTO 7200
  40. 7130 IF BDATE%(3) = 2 THEN DATE$="Mon " : GOTO 7200
  41. 7140 IF BDATE%(3) = 3 THEN DATE$="Tue " : GOTO 7200
  42. 7150 IF BDATE%(3) = 4 THEN DATE$="Wed " : GOTO 7200
  43. 7160 IF BDATE%(3) = 5 THEN DATE$="Thu " : GOTO 7200
  44. 7170 IF BDATE%(3) = 6 THEN DATE$="Fri " : GOTO 7200
  45. 7180 IF BDATE%(3) = 7 THEN DATE$="Sat " : GOTO 7200
  46. 7190 DATE$="*** "       'invalid day of the week
  47. 7200 IF BDATE%(1) = 1 THEN DATE$=DATE$+"Jan" : GOTO 7340
  48. 7210 IF BDATE%(1) = 2 THEN DATE$=DATE$+"Feb" : GOTO 7340
  49. 7220 IF BDATE%(1) = 3 THEN DATE$=DATE$+"Mar" : GOTO 7340
  50. 7230 IF BDATE%(1) = 4 THEN DATE$=DATE$+"Apr" : GOTO 7340
  51. 7240 IF BDATE%(1) = 5 THEN DATE$=DATE$+"May" : GOTO 7340
  52. 7250 IF BDATE%(1) = 6 THEN DATE$=DATE$+"Jun" : GOTO 7340
  53. 7260 IF BDATE%(1) = 7 THEN DATE$=DATE$+"Jul" : GOTO 7340
  54. 7270 IF BDATE%(1) = 8 THEN DATE$=DATE$+"Aug" : GOTO 7340
  55. 7280 IF BDATE%(1) = 9 THEN DATE$=DATE$+"Sep" : GOTO 7340
  56. 7290 IF BDATE%(1) = 10 THEN DATE$=DATE$+"Oct" : GOTO 7340
  57. 7300 IF BDATE%(1) = 11 THEN DATE$=DATE$+"Nov" : GOTO 7340
  58. 7310 IF BDATE%(1) = 12 THEN DATE$=DATE$+"Dec" : GOTO 7340
  59. 7330 DATE$=DATE$+"***"
  60. 7340 DATE$=DATE$+STR$(BDATE%(2))      'add in day of the month
  61. 7345 IF BDATE%(4) < 12 THEN 7380      'see if AM, jump if so.
  62. 7350 ZZFLAG%=-1                       'set pm flag
  63. 7360 IF BDATE%(4) > 12 THEN BDATE%(4)=BDATE%(4)-12   'convert to normal time
  64. 7370 GOTO 7400                        'skip over else
  65. 7380 ZZFLAG%=0                        'it's AM so clear PM flag
  66. 7390 IF BDATE%(4) = 0 THEN BDATE%(4)=12 'if 12 midnight make it 12 not 0
  67. 7400 DATE$=DATE$+STR$(BDATE%(4))+":"  'add hours to print string
  68. 7410 IF BDATE%(5)<10 THEN DATE$=DATE$+"0"  'add leading zero
  69. 7420 DATE$=DATE$+MID$(STR$(BDATE%(5)),2)+":"  'put minutes on
  70. 7430 IF BDATE%(6)<10 THEN DATE$=DATE$+"0"   'add leading zero if required
  71. 7440 DATE$=DATE$+MID$(STR$(BDATE%(6)),2)    'put seconds on
  72. 7450 IF ZZFLAG% THEN DATE$=DATE$+" PM"      'if pm put PM on
  73. 7460 IF NOT ZZFLAG% THEN DATE$=DATE$+" AM" 'if am put AM on
  74. 7470 RETURN
  75. 8000 REM **************************************************
  76. 8010 REM * Get binary date and time into array BDATE%(1-6) *
  77. 8020 REM **************************************************
  78. 8030 REM The array BDATE% is returned with the following
  79. 8040 REM values in it:
  80. 8050 REM     BDATE%(1) = Month number (1-12)
  81. 8060 REM     BDATE%(2) = Day of the month (1-31)
  82. 8070 REM     BDATE%(3) = Day of the week (1-7)
  83. 8080 REM     BDATE%(4) = Hours (0-23)
  84. 8090 REM     BDATE%(5) = Minutes (0-59)
  85. 8100 REM     BDATE%(6) = Seconds (0-59)
  86. 8110 REM
  87. 8120 REM Variables used:
  88. 8130 REM    YYI%, YYFLAG%, YYTMP%
  89. 8140 REM
  90. 8150 REM **************************************************
  91. 8160 REM First get Date and Time in BCD from chip.
  92. 8170 FOR YYI%=1 TO 6
  93. 8180 BDATE%(YYI%)=INP(CBASE%+8-YYI%)    'get bcd value
  94. 8190 NEXT YYI%
  95. 8200 YYFLAG%=0                      'assume date is good and set otherwise
  96. 8210 FOR YYI%=1 TO 6                'read it again and make sure the are equal
  97. 8220 IF INP(CBASE%+8-YYI%) <> BDATE%(YYI%) THEN YYFLAG% = -1  'if not the same set flag
  98. 8230 NEXT YYI%
  99. 8240 IF YYFLAG% = -1 THEN 8170      'try it again if two read not the same
  100. 8250 FOR YYI%=1 TO 6                 'convert numbers from BCD to binary
  101. 8260 YYTMP%=INT(BDATE%(YYI%)/16)       'get left digit
  102. 8270 BDATE%(YYI%)=YYTMP%*10+BDATE%(YYI%)-YYTMP%*16 'all converted
  103. 8280 NEXT YYI%
  104. 8290 RETURN
  105.