! CRS_CVT_TIME.SCP REB, 15-Sep-1989 12:20 .LABEL BEGIN_HERE .IF #DIR NES "F" THEN .GOTO EXIT_PROCEDURE DISPLAY Checking time format . . .\FORCE GET #TIME=#T="" GET #TVALID="Y" GET #T=OA$FIELD_TEXT GET #ORIG_VAL=OA$FIELD_TEXT GET #FN=OA$FIELD_NAME .IF #T EQS "08:30" OR #T EQS "17:00" THEN .GOTO VALID GET #HH=0 .LABEL IS_IT_VALID_24 ! check hours= 00 - 23 and minutes= 00 - 59 and no 'A' or 'P' .IF #T:2 GES "00" AND #T:2 LES "23" AND - #T:1:2 EQS ":" AND - #T:2:3 GES "00" AND #T:2:3 LES "59" AND - #T:1:5 EQS "" THEN - .GOTO VALID .LABEL IS_IT_VALID_12 ! check hours= 01 - 11 and minutes= 00 - 59 and 'A' or 'P' .IF #T:2 GES "01" AND #T:2 LES "12" AND - #T:1:2 EQS ":" AND - #T:2:3 GES "00" AND #T:2:3 LES "59" AND - #T:1:5 EQS "A" OR #T:1:5 EQS "P" THEN - .GOTO CONVERT_12_TO_24 ! check for possible '5:15p' .IF #T:1 NES "" AND #T:1:1 EQS ":" THEN - .GOTO ADD_ZERO ! check for possible ' 5:15p' .IF #T:1 EQS "" AND #T:1:2 EQS ":" THEN - .GOTO ADD_ZERO_REMOVE_SPACE .GOTO INVALID .LABEL ADD_ZERO GET #T="0" #T:5 ! check for "05:15 " .IF #T:1:5 EQS "" THEN .GOTO ADD_AM .GOTO IS_IT_VALID_12 .LABEL ADD_ZERO_REMOVE_SPACE GET #T="0" #T:5:1 ! check for "05:15 " .IF #T:1:5 EQS "" THEN .GOTO ADD_AM .GOTO IS_IT_VALID_12 .LABEL ADD_AM GET #T=#T:5 "A" .GOTO IS_IT_VALID_12 .LABEL CONVERT_12_TO_24 ! check for hours= 01 - 11 A .IF #T:2 GES "01" AND #T:2 LES "11:00" AND - #T:1:5 EQS "A" THEN - GET #T=#T:5 ! check for hour = 12 A .IF #T:2 EQS "12" AND #T:1:5 EQS "A" THEN - GET #T = "00:" #T:2:3 ! check for hour = 12 P .IF #T:2 EQS "12" AND #T:1:5 EQS "P" THEN - GET #T = #T:5 ! check for hours= 01 - 11 P .IF #T:2 GES "01" AND #T:2 LES "11" AND - #T:1:5 EQS "P" THEN - .GOTO ADD_12 .GOTO IS_IT_VALID_24 .LABEL ADD_12 GET #H = #T:2 COMPUTE #HH = #H + 12 GET #T=#HH #T:3:2 .GOTO IS_IT_VALID_24 .LABEL VALID GET #TVALID="Y" OA$VAL_SET_VALID GET #TIME=#T DISPLAY\FORCE .IF #TIME LES "07:30" THEN .GOTO TOO_EARLY .GOTO EXIT_PROCEDURE .LABEL TOO_EARLY .CLEAR 16,8 .TEXT 17,31,"C A U T I O N !" .TEXT 19,5,- "The time you specified is EARLY morning. If you intended to indicate" .TEXT 20,5,- "an afternoon time, please put a 'p' after the time so that it will" .TEXT 21,5,- "translate to the proper 24-hour time." .PROMPT 23,5,"Do you want to re-enter the time? [Y/N] " CLEAR .IF OA$SCRIPT_PSIB:1 EQS "N" THEN .GOTO EXIT_PROCEDURE .IF OA$SCRIPT_PSIB:1 NES "Y" THEN .GOTO TOO_EARLY GET OA$FUNCTION=- "OA$FRM_SET_FIELD " #FN GET #TIME=#ORIG_VAL GET OA$FUNCTION=- "GET " #FN "=" #T GET #TVALID="N" .GOTO EXIT_PROCEDURE .LABEL INVALID GET OA$FUNCTION=- "OA$FRM_SET_FIELD " #FN GET OA$FUNCTION=- "GET " #FN "=" #T GET #TVALID="N" OA$MSG_PURGE DISPLAY - Use 12-hour time of 12:00A-11:59P or 24-hour time of 00:00-23:59. .GOTO EXIT_PROCEDURE .LABEL EXIT_PROCEDURE .EXIT